0
我想有重定向到的所有請求http://example.com/controllerhttp://example.com/index.php/controller不改變的URL,這是我的.htaccess文件看起來像:URL重寫將所有請求http://example.com/controller重定向到http://example.com/index.php/controller不改變網址
# Customized error messages.
ErrorDocument 404 /index.php
# Set the default handler.
DirectoryIndex index.php
# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
RewriteBase/
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301]
</IfModule>
不幸的是,這是行不通的。到http://example.com/controller所有請求被路由到家庭控制器和URL不會改變。 而所有的請求http://www.example.com/controller被路由到http://example.com/index.php/controller和網址中的地址欄更改。
感謝您的快速反應!我試過了,但仍然有同樣的問題。像http://myurl.com/controller或http://www.myurl.com/controller(使用www)的所有查詢都會導致默認主頁。任何想法爲什麼? – itwasthewind 2010-08-01 23:03:45
聽起來不像.htaccess問題。我認爲你需要弄亂你的config/routes.php文件。 – Keyo 2010-08-02 05:08:52
在codeigniter中,我的routes.php文件只有兩行: $ route ['default_controller'] =「Home」; $路線[ 'scaffolding_trigger'] = 「」; 我還應該添加什麼? – itwasthewind 2010-08-02 07:04:54