事实证明,由于不同的原因,我必须更改我的网站网址,旧的网址已在Google中编入索引,我希望您浏览它们,新内容会以新网址显示。
我补充说:
Redirect 301 /library/books/pitz-lower.php http://www.example.com/library/pitz-lower.php
但是要从谷歌获取,浏览器中的网址如下所示:
http://www.example.com/library/pitz-lower.php?url=library/pitz-lower
htaccess的
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /library/library\.php\?url=([^\s]+) [NC]
RewriteRule ^ /library/%1.php? [L,R=301]
RewriteCond %{REQUEST_URI} !^/library/library\.php
RewriteRule ^library/(.+)\.php$ /library/library.php?url=$1 [L]
</IfModule>
#r301
Redirect 301 /library/books/pitz-lower.php http://www.example.com/library/pitz-lower.php
我不明白为什么会这样,有人帮我一把?谢谢!!
答案 0 :(得分:1)
有两个问题:
mod_rewrite
规则和mod_alias
规则(即Redirect
指令)并不好,因为这两个模块在不同时间运行。301
重定向规则。您修改后的.htaccess应为:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^library/books/pitz-lower\.php$ /library/pitz-lower.php [L,NC,R=301]
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /library/library\.php\?url=([^\s]+) [NC]
RewriteRule ^ /library/%1.php? [L,R=301]
RewriteCond %{REQUEST_URI} !^/library/library\.php
RewriteRule ^library/(.+)\.php$ /library/library.php?url=$1 [L,QSA]
请记住在测试时清除浏览器缓存。