I am creating a website in Codeigniter. This is very common issue I know and there are lots of solutions on Stack Overflow. I try almost all but nothing is helpful for me.
I just want to remove index.php from my url. Anybody please tell me how can I do it?
I have removed index.php from the config file's $config['index_page']
section
I also checked $config['uri_protocol'] = 'AUTO';
mode try both mode auto and REQUEST_URI
.
My .httaccess file structure right now is this:
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
Can anybody please tell me how to do it?
$config['uri_protocol']
should be REQUEST_URI
and then .htaccess
as follows
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
I have the following and works fine for me:
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|downloads|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]
$config['index_page'] = ''; $config['uri_protocol'] = 'AUTO';
RewriteEngine on RewriteCond $1 !^(index\\.php|resources|robots\\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Note: .htaccess
vary depending on server. In some server (eg: Godaddy) need to use the following .htaccess
:
RewriteEngine on RewriteCond $1 !^(index\\.php|resources|robots\\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
try this ...
RewriteEngine On
RewriteBase /music
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
Rewrite Base /music is your folder name
=> Change in config file :-
$config['base_url'] = 'http://123456/proj/';
$config['index_page'] = '';
=> change in .htaccess file :-
RewriteEngine on
RewriteCond $1 !^(index\.php|
(.*)\.swf|forums|images|css|downloads|jquery|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]
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.