0

我正在尝试使用www.hostname.com/crm/some/url将 CodeIgniter 框架中的 url 重定向到www.hostname.com/index.php?/some/url

我在我的 .htacess 中写了以下规则

RewriteEngine on
RewriteRule ^crm(.*)$ index.php?/$1     [L]

当我在浏览器中尝试此操作时,我从 codeIngnitor 获得页面未找到 404。但是,如果在重定向规则中添加 [R] 标志,它可以正常工作,并且我可以在更改后按预期看到新的 url。

我试过apache重写日志。一切看起来都很合适。我没有重写后 CodeIgniter 框架看到的 URL。任何帮助表示赞赏。

4

2 回答 2

1

您是否有理由不使用典型的 Codeigniter .htaccess?

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
于 2012-12-30T03:40:11.337 回答
0

您可以按照此操作,将此代码复制并粘贴到您的 .htaccess 文件中。我想它会对你有所帮助。

RewriteEngine on
RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|uploads|themes|downloads|jquery|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]
于 2016-12-15T06:39:32.020 回答