2014-10-27 167 views
0

我正在为一个网站搜索引擎优化,并希望纠正一些“未找到”由谷歌网站管理员工具提供的网址。问题htaccess重写规则

所以我开始在.htaccess文件中这样做。

http://www.chateau-de-beaugency.com/fr/index.php?id=12 

应该

http://www.chateau-de-beaugency.com/fr/infos-legales-12 

http://www.chateau-de-beaugency.com/fr/index.php?id=42 

应该

http://www.chateau-de-beaugency.com/fr/acces-presse-42 

http://www.chateau-de-beaugency.com/fr/index.php?id=11 

应该是

http://www.chateau-de-beaugency.com/fr/nous-contacter-11 

http://www.chateau-de-beaugency.com/fr/index.php?id=13 

应该是

http://www.chateau-de-beaugency.com/fr/plan-du-site-13 

http://www.chateau-de-beaugency.com/fr/fr/-6/les-services-35/index.php?id=13 

应b Ë

http://www.chateau-de-beaugency.com/fr/plan-du-site-13 

http://www.chateau-de-beaugency.com/fr/fr/-6/les-services-35/index.php?id=12 

应该

http://www.chateau-de-beaugency.com/fr/infos-legales-12 

http://www.chateau-de-beaugency.com/fr/chateau-de-beaugency.com/fr/ 

应该

http://www.chateau-de-beaugency.com/fr/ 

谢谢您的帮助

回答

0

您可以在DOCUMENT_ROOT/.htaccess文件中使用此代码:

RewriteEngine On 
RewriteBase/

RewriteCond %{THE_REQUEST} \s/+/fr/fr/-6/les-services-35/index.php?id=12 [NC,OR] 
RewriteCond %{THE_REQUEST} \s/+fr/index\.php?id=12\s [NC] 
RewriteRule^/fr/infos-legales-12? [R=302,L] 

RewriteCond %{THE_REQUEST} \s/+(fr)/index\.php?id=(42)\s [NC] 
RewriteRule^/%1/acces-presse-%2? [R=302,L] 

RewriteCond %{THE_REQUEST} \s/+(fr)/index\.php?id=(11)\s [NC] 
RewriteRule^/%1/acces-presse-%2? [R=302,L] 

RewriteCond %{THE_REQUEST} \s/+(fr)/fr/-6/les-services-35/index.php?id=13\s [NC,OR] 
RewriteCond %{THE_REQUEST} \s/+(fr)/index\.php?id=13\s [NC] 
RewriteRule^/%1/plan-du-site-13? [R=302,L] 

RewriteCond %{THE_REQUEST} \s/+(fr)/chateau-de-beaugency.com/fr/\s [NC] 
RewriteRule^/%1/? [R=302,L] 

# internal forward from pretty URL to actual one 
RewriteRule ^(fr)/name-([^/]+)/?$ $1/index.php?id=$2 [L,QSA,NC] 
+0

您好,感谢你的小费,但遗憾的是它不工作。我想要这个: http://www.chateau-de-beaugency.com/fr/index.php?id=12 去那里: http://www.chateau-de-beaugency .com/fr/infos-legales-12 我有此消息: “未找到请求的URL /fr/index.php在此服务器上未找到。” .htaccess位于我的虚拟主机的根目录下。 广告是有其他规则,我可以发送原始文件,如果你想要? – nitneroc 2014-10-30 11:29:37

+0

谢谢,它在这里:http://pastebin.com/XuURjj3M – nitneroc 2014-10-30 11:39:13

+0

是的它有所不同,实际上有7个不同的网址谷歌网站管理员工具告诉我是404。 我猜他们是由机器人索引的网址,然后我改正了我的rewriteRules(这很好用),所以它首先将我的规则配置错误,从而将一些重复的Url与旧网址混合编入索引。如果我清楚。 – nitneroc 2014-10-30 12:07:45