foo.com 및 foo.net 형식의 두 도메인이 있습니다.파킹 된 도메인 (htaccess) 리디렉션
# Rewrite URL to force WWW
RewriteCond %{HTTP_HOST} ^[^.]*\.[^.]*$
RewriteCond %{SERVER_PORT} !=443
RewriteRule^http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} ^[^.]*\.[^.]*$
RewriteCond %{SERVER_PORT} =443
RewriteRule^https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.(.*\.[^.]*\.[^.]*)$ [NC]
RewriteCond %{SERVER_PORT} !=443
RewriteRule^http://%1%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.(.*\.[^.]*\.[^.]*)$ [NC]
RewriteCond %{SERVER_PORT} =443
RewriteRule^https://%1%{REQUEST_URI} [R=301,L]
는 그러나, 나는 하위 도메인을 포함하여 .COM로 이동 그물로 끝나는 URL을 리디렉션 할 : 저는 현재 WWW에 www가 아닌 리디렉션 내의 .htaccess에 다음 있습니다. 예 :
foo.net -> foo.com
www.foo.net -> www.foo.com
foo.net/bar -> foo.com/bar
sub.foo .NET -> sub.foo.com
sub.foo.net/bar -> sub.foo.com/bar
나는 다른 사이트에 이것을 가지고하는 데 사용하지만, 몇 년 전 내가 돈 더 이상 .htaccess가 없습니다. 아무도이 일을하는 쉬운 방법을 알고 있습니까?
편집 : 여기에 htaccess로의 나머지 부분입니다 :
# BEGIN WordPress
#
RewriteEngine on
#
# Unless you have set a different RewriteBase preceding this point,
# you may delete or comment-out the following RewriteBase directive
# RewriteBase/
#
# if this request is for "/" or has already been rewritten to WP
RewriteCond $1 ^(index\.php)?$ [OR]
# or if request is for image, css, or js file
RewriteCond $1 \.(gif|jpg|png|php|ico|css|js)$ [NC,OR]
# or if URL resolves to existing file
RewriteCond %{REQUEST_FILENAME} -f [OR]
# or if URL resolves to existing directory
RewriteCond %{REQUEST_FILENAME} -d
# then skip the rewrite to WP
RewriteRule ^(.*)$ - [S=1]
# else rewrite the request to WP
RewriteRule . /index.php [L]
#
# END wordpress
# Rewrite URL to force WWW
-(see top of post)-
그것은 작동하지 않았다 문제가있다 - 할 때마다 일치하는 URL을 다시 써서 나머지 URL (% {REQUEST_URI})을 차단하고 www.foo.com을 남깁니다. – StormPooper
서버의 액세스 및 오류 로그에 액세스 할 수 있습니까? 내 테스트 서버 (WordPress 규칙 포함)에서도 정상적으로 작동하므로 사용자 환경에서 500 오류가 발생하는 이유는 무엇입니까? 우리가 그걸 알아낼 수 없다면 대신에 사용할 수있는 덜 조밀 한 솔루션을 쓸 수 있습니다. –