我写了一条重写规则,让所有页面看起来像
dealer_listings.php?territory=arizona
可以像这样访问
wholesale-parts/arizona/
我希望这个丑陋的网址也能重定向到友好的网站。
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]
答案 0 :(得分: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]