我的.htaccess文件中包含以下代码:
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 :(得分:0)
尝试使用rewriterule而不是Redirect(我认为在重定向规则之前应用重写规则)。如下所示:
RewriteRule ^index.asp / [R=301,L]
RewriteRule ^contact.asp /contact.php [R=301,L]
PS。您可以删除第一个规则,因为您已经重写了每个index.xxx文件。
答案 1 :(得分: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}