经过很多次,我真的不明白为什么我的重写规则不行。我使用CI框架,当我在URI中设置/ france时,我需要转到controller / show / place / 1.
这是我的代码:
Options +FollowSymLinks
SetEnv PHP_VER 5
AddDefaultCharset UTF-8
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt|img\/|css\/|js\/|favicon.ico)
RewriteRule ^(.*)$ /index.php/$1 [PT,L]
RewriteRule ^france$ index.php/show/place/1 [PT,L]
有人可以帮我吗?
答案 0 :(得分:2)
为此使用Codeigniter URI路由更加方便,请参阅http://ellislab.com/codeigniter%20/user-guide/general/routing.html
答案 1 :(得分:0)
尝试修改规则的顺序:
Options +FollowSymLinks
SetEnv PHP_VER 5
AddDefaultCharset UTF-8
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt|img\/|css\/|js\/|favicon.ico)
RewriteRule ^france$ index.php/show/place/1 [PT,L]
RewriteRule ^((?!index\.php/).*)$ /index.php/$1 [PT,L]
答案 2 :(得分:0)
看一下URI路由类http://ellislab.com/codeigniter%20/user-guide/general/routing.html 对于你的问题这里是一个片段 转到/application/config/routes.php 并添加:
$route['france'] = 'show/place/1';
<。>在.htaccess文件中删除index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|img|css|js|robots\.txt)
RewriteRule (.*) index.php?/$1 [L]
答案 3 :(得分:0)
您是否还将config.php $ config ['index_page']设置为空白?
更改$config['index_page'] = 'index.php';
到 - &gt; $config['index_page'] = '';