htaccess的mod_rewrite的没有重复的内容 [英] htaccess mod_rewrite no duplicate content
本文介绍了htaccess的mod_rewrite的没有重复的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经写了重写规则来获取所有的页面看起来像
dealer_listings.php?境内=亚利桑那州
可以访问这样的
批发零部件/亚利桑那州/
我想丑陋的URL重定向到搜索引擎友好的之一,也是。
选项-MultiViews
RewriteEngine叙述上
< FILES的.htaccess>
为了允许,拒绝
所有否认
< /文件>
重写规则^([^ / \。] +)/ +([^ / \。] +)/([^ / \。] +)/?$ bussiness_profile.php?什么= $ 1和2型= $&放大器;经销商= $ 3 [L]
重写规则^批发零部件/([^/\.]+)/?$ dealer_listings.php?境内= $ 1 [R = 301,L]
的RewriteCond%{HTTP_HOST} ^ www.elite-dealers.com [NC]
重写规则^(。*)$ http://elite-dealers.com/$1 [R = 301,NC]
重写规则^(([^ /] + /)*)指数\ .PHP http://elite-dealers.com/$1 [R = 301,L]
解决方案
添加以下code到你的.htaccess文件重定向丑陋的URL到搜索引擎友好的。
#如果请求的是dealer_listings
的RewriteCond%{REQUEST_URI} ^ / dealer_listings \ .PHP $ [NC]
#,然后它有一个领土参数
的RewriteCond%{QUERY_STRING} ^境内=([^&功放;] +)[NC]
#then 301重定向到搜索引擎友好的版本
重写规则。批发部件/ 1%/? [L,R = 301]
I have written a rewrite rule to get all pages looking like
dealer_listings.php?territory=arizona
to be accessible like this
wholesale-parts/arizona/
I would like the ugly url to redirect to the seo friendly one as well.
Options -MultiViews
RewriteEngine on
<FILES .htaccess>
order allow,deny
deny from all
</FILES>
RewriteRule ^([^/\.]+)/+([^/\.]+)/([^/\.]+)/?$ bussiness_profile.php? what=$1&type=$2&dealer=$3 [L]
rewriterule ^wholesale-parts/([^/\.]+)/?$ dealer_listings.php?territory=$1 [R=301,L]
rewritecond %{http_host} ^www.elite-dealers.com [nc]
rewriterule ^(.*)$ http://elite-dealers.com/$1 [r=301,nc]
RewriteRule ^(([^/]+/)*)index\.php http://elite-dealers.com/$1 [R=301,L]
解决方案
Add the following code to your .htaccess file to redirect the ugly URL to the SEO friendly one.
#if the request is for dealer_listings
RewriteCond %{REQUEST_URI} ^/dealer_listings\.php$ [NC]
#and it has a territory parameter
RewriteCond %{QUERY_STRING} ^territory=([^&]+) [NC]
#then 301 redirect to the SEO friendly version
RewriteRule . wholesale-parts/%1/? [L,R=301]
这篇关于htaccess的mod_rewrite的没有重复的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文