2017-09-24 2 views
0

하위 디렉토리를 하위 도메인으로 리디렉션하고 싶지만 사이트 맵에 대한 엔드 포인트를 유지 관리해야합니다.리디렉션 301 htaccess가있는 URL에 문자열이있는 경우 제외

은 내가해야 할 것은 :

Redirect 301 /ru/ https://ru.mydomain.com 
#Exclude *sitemap* 

이 URL을 이런 종류의 리디렉션 할 수 없습니다

https://www.mydomain/ru/sitemap.xml 
https://www.mydomain/ru/sitemap.1.xml 
https://www.mydomain/ru/sitemap.3.xml 
https://www.mydomain/ru/sitemap_ru.xml 

모든 맵 문자열을하고 난 사이트 맵 단어가 URL에있을 때 더 리디렉션 할 필요가 없습니다. 희망은 도움이 될 수 있습니다. 많은 시간을 들여서 행운을 빕니다.

내가 좋아하는 필요

{if *sitemap* is not present} 
Redirect 301 /ru/ https://ru.mydomain.com 
{/if} 

감사합니다!

+0

아파치 버전이란 무엇입니까? –

답변

0

이 방법이 유용 할 것입니다. 웹 사이트 (www.mydomain)의 URL이/ru로 시작하지만/ru/sitemap이 아닌 경우 ... (301)은 https://ru.mydomain.com/으로 리디렉션되지만 경로에는/ru가 없습니다. 예 : https://www.mydomain/ru/news는 NC 플래그는이 경우에 둔감하다는 것을 의미 https://ru.mydomain.com/news

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^www\.mydomain$ [NC] 
RewriteCond %{REQUEST_URI} ^/?ru(/.*)?$ [NC] 
RewriteCond %{REQUEST_URI} !^/?ru/sitemap.*$ [NC] 
RewriteRule ^/?ru(/(.*))?$ https://ru.mydomain.com/$2 [R=301,L] 

간다. mod_rewrite 설치 끝내기가 필요합니다!