2011-11-14 24 views
0

我在我的.htaccess文件下面的代碼:重定向301的RewriteCond碰撞

Options +FollowSymLinks 
RewriteEngine On 

Redirect 301 /index.asp  http://www.website.com/index.php 
Redirect 301 /contact.asp http://www.website.com/contact.php 

RewriteCond %{REQUEST_METHOD} !POST 
RewriteRule ^(.*/)?index\.([a-zA-Z0-9]{3,4})$ /$1 [R=301,L] 

ErrorDocument 404 error.php 
RewriteRule ^sitemap.xml sitemap.php 

RewriteCond %{ENV:REDIRECT_STATUS} 200 
RewriteRule .* - [L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

RewriteCond %{REQUEST_URI} ^(.*)$ 
RewriteRule (.*) seofile.php?word=%{REQUEST_URI} 

現在, 出於某種原因,當我進入contact.asp我越來越

http://www.website.com/seofile.php?word=/contact.asp 

我該如何解決它?

回答

0

嘗試使用rewriterule而不是重定向(我認爲重寫規則應用於重定向規則之前)。因此類似於:

RewriteRule ^index.asp /   [R=301,L] 
RewriteRule ^contact.asp /contact.php [R=301,L] 

PS。可以刪除第一條規則,因爲您已經重寫了每個index.xxx文件。

0

建議:嘗試分離不屬於RewriteRules的事物。

試試這個代碼,請告訴我,如果它的工作原理:

ErrorDocument 404 error.php 

Options +FollowSymLinks 
RewriteEngine On 

RewriteRule ^(index|contact)\.asp $1.php [QSA,R=301,L] 
RewriteRule ^sitemap\.xml$ sitemap.php [L] 

RewriteCond %{REQUEST_METHOD} !POST 
RewriteRule ^(.*/)?index\.([a-zA-Z0-9]{3,4})$ /$1 [R=301,L] 

RewriteCond %{ENV:REDIRECT_STATUS} 200 
RewriteRule (.*) - [L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule (.*) seofile.php?word=%{REQUEST_URI}