繁体   English   中英

htaccess RewriteRule问题

[英]issue with htaccess RewriteRule

我正在为网站进行SEO,并想更正Google网站站长工具提供的一些“未找到” URL。

因此,我开始在.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

应该

 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/

谢谢您的帮助

您可以在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]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM