As my title said, I successfully remove index.php
from URL, but apparently when I type " index.php?
", it is not working. I have googled everything but found nothing with this issue.
Here is the code in my .htaccess
(I am using CI also):
RewriteEngine On
RewriteBase /
RewriteRule ^index.php/(.*)$ $1 [R=301,L]
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
Thank you in advance!
Add this rule on top of other rules to remove index.php:
# remove index.php
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(.*?)index\.php$ $1%{QUERY_STRING}? [L,R=302,NC,NE]
You can take your application folder out of the system folder and use this code:
RewriteEngine On
RewriteRule ^index.php/(.*)$ /$1 [R=302,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]
It should work.
And from config/config.php
file make enable_query_strings
FALSE
:
$config['enable_query_strings'] = FALSE;
Follow this which may help you http://ellislab.com/codeigniter/user-guide/general/urls.html
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
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.