codeigniter htaccess代码问题与301重定向

时间:2014-03-18 11:57:34

标签: .htaccess codeigniter mod-rewrite redirect

我们在.htaccess中使用codeiniter index.php删除代码,它对我们来说很好。但是我们在.htacess和codeiniter代码中有一些重定向与我们的重定向页面配对。

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]


Redirect 301 /articles/page-title.html http://domain.com/p/page-title.html

我们重定向如下:" http://domain.com/p/page-title.html?/articles/page-title.html"

我们如何修复和删除额外的"?/ articles / page-title.html"我们的重定向网址?

thaks

2 个答案:

答案 0 :(得分:0)

.htaccess中尝试使用此功能。请注意,我已将您的重定向进一步提升

RewriteEngine on
RewriteBase /
Redirect 301 /articles/page-title.html http://domain.com/p/page-title.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

答案 1 :(得分:0)

我解决了一个类似的问题,它在最后追加旧字符串?使用带有301而不是重定向的RewriteRule。这与首先​​发生的重写规则有关。把这条线放在RewriteBase之后,所以你的看起来像这样...

RewriteEngine on
RewriteBase /
RewriteRule ^(/articles/page-title.html)$ /p/page-title.html [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]