2012-07-12 54 views
1

很愚蠢的是,我发送了一条通讯,没有检查链接。其中一个是坏的,所以我想用htaccess来处理这个问题。htaccess重定向url中的空格

我是被链接到网址是:

http://www.domain.com.au/www.domain.com.au/campers-and-motorhomes/ne%20w-zealand/camper-rentals/

在实际页面: http://www.domain.com.au/campers-and-motorhomes/new-zealand/camper-rentals/

注意,在新的空间新西兰以及额外www.domain.com .au

如何在htaccess中设置?

感谢

回答

1

既然你没有操纵URL,你可以使用一个简单Redirect

Redirect /www.domain.com.au/campers-and-motorhomes/ne%20w-zealand/camper-rentals/ http://www.domain.com.au/campers-and-motorhomes/new-zealand/camper-rentals/ 

编辑如果Apache不喜欢的空间未加引号为%20,尝试一个真正的空间引述了整个事情在那里:

Redirect "/www.domain.com.au/campers-and-motorhomes/ne w-zealand/camper-rentals/" http://www.domain.com.au/campers-and-motorhomes/new-zealand/camper-rentals/ 

Edit2如果它追加了一个查询字符串,你将需要使用mod_rewrite来摆脱查询字符串,而不是简单的重定向,恐怕。

RewriteEngine On 
# If the request starts with www.domain.com.au, it is the broken link 
# Rewrite to the proper URL and put ? on the end to remove the query string 
RewriteRule ^www\.domain\.com\.au http://www.domain.com.au/campers-and-motorhomes/new-zealand/camper-rentals/? [L,R=301] 
+0

谢谢。我是htaccess的总新手,是否需要进入块,还是只能坐在自己的位置? – Fraser 2012-07-12 01:55:20

+1

@Fraser从技术上讲,它是mod_alias的一部分,所以你可以将它封装在''的一侧,但这可能不是必须的,因为mod_alias只是总是安装并启用。 – 2012-07-12 01:56:28

+0

再次感谢。不幸的是,它没有拿起页面。它似乎是抛出它的空间(重定向与没有空间的其他URL一起工作)。我尝试用\转义它,但这给我一个内部服务器错误。有任何想法吗? – Fraser 2012-07-12 02:02:05