【发布时间】:2015-12-09 09:22:19
【问题描述】:
我正在使用 Codeigniter 3 并拥有以下 htaccess 文件:
RewriteEngine on
# Allow redirect.phps which are setup
RewriteCond %{REQUEST_URI} register.php
RewriteRule ^/?([A-Za-z]{2})/register.php /redirect.php/$1 [NC,L]
RewriteRule ^/?register.php /redirect.php/uk [NC,L]
RewriteRule ^/?([A-Za-z]{2})/images/(.*)$ /images/$1/$2 [NC,L]
RewriteCond %{REQUEST_URI} !^/images/([^/]+)/ [NC]
RewriteCond $1 !^(index\.php|css|jscript|convert\.php|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
我在http://htaccess.mwl.be/ 上测试过,格式正确,有人告诉我:
- 新的网址是http://my.local/redirect.php/uk
- 测试因 RewriteRule 选项中的 L 而停止。
太好了。但由于某种原因,我得到了 Codeigniter 404 页面?? Codeigniter 肯定永远不会看到我的代码吗?如果我在 index.php 文件中放一个简单的 hello+exit ,我可以清楚地看到 Codeigniter 正在传递参数,那么我到底做错了什么?
【问题讨论】:
-
您是否尝试在 config.php 文件中设置 $base_url?
-
是的 - 它设置为 $config['base_url'] = 'my.local';
-
好的,假设您的应用程序位于您的根目录中,请尝试更改 .htaccess 像这样
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_URI} ^system.* RewriteRule ^(.*)$ /index.php?/$1 [L] RewriteCond %{REQUEST_URI} ^application.* RewriteRule ^(.*)$ /index.php?/$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [L] RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L] </IfModule> -
@Ukuser32 你的网址是什么?
-
应该是 my.local - 我在本地测试它
标签: .htaccess codeigniter mod-rewrite