【问题标题】:htaccess mod_rewrite no duplicate contenthtaccess mod_rewrite 没有重复的内容
【发布时间】:2011-11-28 23:43:53
【问题描述】:

我已经写了一个重写规则来让所有页面看起来像

dealer_listings.php?territory=arizona

像这样可以访问

wholesale-parts/arizona/

我希望丑陋的网址也重定向到对 seo 友好的网址。

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]

【问题讨论】:

  • 只是一个建议:保持大小写“同质化”是始终的好习惯。 C++区分大小写,Php区分大小写,C区分大小写等等,所以尽量养成这个习惯...

标签: .htaccess mod-rewrite


【解决方案1】:

将以下代码添加到您的 .htaccess 文件中,以将丑陋的 URL 重定向到对 SEO 友好的 URL。

#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]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-05
    • 2011-09-17
    • 2010-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多