开发者

Cannot remove index.php from my urls in Codeigniter

I am using codeigniter and when I set up the website I 开发者_C百科added necessary code in my .htaccess file to remove index.php (default) from my urls. I just happened to replace my public_html folder from a back up file of my website. Since I did that, I cannot get any of the links on home page to work unless insert index.php in the url between the domain name and the rest of the url as in http://www.obsia.com/index.php/contact/ instead of http://www.obsia.com/contact/ and it works. So, in my config file within the application folder, I changed

$config['index_page'] = "";  

to

$config['index_page'] = "index.php";

and all the links seem to work now. But how do I remove index.php from the URLs.

Here is what my .htaccess code looks like:

RewriteEngine on
RewriteBase / 
RewriteCond $1 !^(index\.php|public|user_guide|robots\.txt|css)
RewriteRule ^(.*)$ /index.php?/$1 [L]

Can anyone point me in the right direction. It will much appreciated.

Regards, G


What yo want to do can be done this way:

RewriteEngine on
RewriteBase / 
# Static content. Rewrite to - (don't change) and mark as last rule.
RewriteRule !^(index\.php|public|user_guide|robots\.txt|css) - [L]

# Do the rewrite.
RewriteRule ^(.*)$ /index.php?/$1 [L]

However, a slightly better way of doing that is this:

RewriteEngine on
RewriteBase / 
# Only do the rewrite under the condition that the requested URL isn't a (real) file.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?/$1 [L]


there are so many ht access files... In my case i was editing the wrong file... u should edit the file that is inside the project.. for example i work on code igniter and project name was test , so inside test folder i had a htaccess file and inside my application folder ie test/application there was another htaccess file.. i was editing the access file inside the application folder, but i had to edit the file in test folder not test/application/.htaccess.... hope sum 1 finds this useful.. cos i spent half a day to figure this out :(

Cheers ksp

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜