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


Does this rule exist in /myapp/.htaccess

:



RewriteEngine On
RewriteBase /myapp/

# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.+) index.php/$1 [L]

      

+1


source


Try this in htaccess

RewriteEngine on 
RewriteCond %{THE_REQUEST} /myapp/xyz/([^.]+)\.html [NC]
RewriteRule ^ /myapp/index.php/xyz/%1.html [R,L,NC]

      

0


source







All Articles