2011-10-09 88 views
1

嗨,我想请教各位.htacess 301重定向:何使.htacess重定向,并保持完整的URL路径

我有例如路径许多动态网址是这样的:

http://www.domain.com/post1.html 
http://www.domain.com/post2.html 

和我需要将其重定向到相同的URL,但有一点不同的网域(不含WWW):

http://domain.com/post1.html 
http://domain.com/post2.html 

我已经这样做了:

Options +FollowSymLinks 
RewriteEngine On 
RewriteCond %{HTTP_HOST} ^www.domain.com 
RewriteRule (.*) http://domain.com/$1 [R=301,L] 

重定向的作品,但我正常的网址变得网址的ID,如:

http://domain.com/index.php?id=931 

不喜欢它应该是:

http://domain.com/post1.html 

任何意见或直升机赞赏。 谢谢。

+0

把所有.htaccess内容放在这里! – undone

回答

0

显然你在这里发生了一些其他的重写规则,但是对于你给我们的东西,你可以试着在之前添加这个,以便让它停止处理一个已被重写的URL:

RewriteCond %{QUERY_STRING} id=[0-9]+ 
RewriteRule ^index.php - [L] 
+0

是的,你是对的,它之前设置了其他规则,我只是提高了我的规则,一切都很顺利! – Tim