简体   繁体   中英

how to remove index.php from url using .htaccess

I'm working on yii framework and trying to remove index.php from url (httpx://localhost:801/index.php/aImages) it should be like this httpx://localhost:801/aImages . So the code given below is in my .htaccess file. This code is working on my localhost but not my team members machine.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>

try :

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php

and in your config file, use:

...
'urlFormat'=>'path',
'showScriptName'=>false,
...

You need to create .htaccess file

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]

You can check here for further reference.

RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php

reference : http://www.yiiframework.com/doc/guide/1.1/en/topics.url

试试这个规则

RewriteRule ^index\.php/$ $1 [R=301,L]

最后一行应该是

RewriteRule (.*) index.php/$1 [L]

Go to .htaccess file and add the following lines...

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM