0

我想在 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写的旧网站

4

2 回答 2

2

将第二个更特殊的规则移到通常 CI 的 nice url 的 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]
于 2013-06-25T08:00:00.750 回答
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]
于 2013-06-25T07:59:53.253 回答