我想在codeigniter中删除index.php后进行301重定向。
htaccess文件:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|img|js|plugins|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
在此之后我添加了
RewriteRule /index.php?page=9-someting&txt=12 /page/1/someting#2/other [R=301,L]
但重定向不起作用吗?
编辑:
/index.php?page=9-someting&txt=12未在CodeIgniter中编写的旧网站
答案 0 :(得分:2)
在通常的CI的好网址的catch-all-and-send-to-index规则之前移动你的第二个更特殊的规则。您可能还想添加NE
(不进行编码),因为哈希标记(#
)将以其他方式编码。
这样的事情:
RewriteEngine on
# rewrite old site url, has L so processig will stop here for matching requests.
RewriteCond %{QUERY_STRING} ^page=9-someting&txt=12$
RewriteRule index.php /page/1/someting#2/other [R=301,L,NE]
# request that fall trouhg will be sent to CI's front controller (if they are not images, css....)
RewriteCond $1 !^(index\.php|images|css|img|js|plugins|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
答案 1 :(得分:0)
在.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L,R=301]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,R=301]
</IfModule>
RewriteRule ^index.php?page=9-someting&txt=12$ /page/1/someting#2/other [R=301,L]