2011-11-28 1 views
0

중복 내용을 mod_rewrite에 없습니다 친절한 사람도.htaccess로 모든 페이지가이</p> <pre><code>wholesale-parts/arizona/ </code></pre> <p>내가 현서로 리디렉션 추악한 URL을 좋아하는 것처럼 액세스 할 수</p> <pre><code>dealer_listings.php?territory=arizona </code></pre> <p>처럼 보이는 얻을 나는 재 작성 규칙을 작성했습니다

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

그냥 충고 : 대문자와 소문자가 "균질"인 것은 항상 좋은 습관입니다. C++은 대소 문자를 구별합니다. PHP는 대소 문자를 구별합니다. C는 대소 문자를 구별합니다. 그래서이 버릇을 찾으십시오. –

답변

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]