htaccess的mod_rewrite的没有重复的内容内容、htaccess、mod_rewrite

2023-09-02 20:34:34 作者:你我终不遇

我已经写了重写规则来获取所有的页面看起来像

  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]
 
Z玩主 岂止于白 不一样的 纯白主机

解决方案

添加以下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]