How to add index.php to url via htaccess
Actually I need to add index.php to my app url via htaccess file.
My url looks like this.
http://localhost:8080/myapp/xyz/abs.html
I need to change this.
http://localhost:8080/myapp/index.php/xyz/abs.html
Can anyone tell me what I need to write in the htaccess file.
Any help would be appreciated.
Thank.
+3
source to share
3 answers
Presumably an internal rewrite is required and not an external redirect? In that case, try something like the following using mod_rewrite in your root .htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_URI} !/index\.php/
RewriteRule ^myapp/(.*) /myapp/index.php/$1 [L]
The directive RewriteCond
is required to prevent a rewrite cycle. (Only rewrite if it doesn't already contain "/index.php/".)
+1
source to share