htaccess的重定向URL与它的空间它的、重定向、空间、htaccess

2023-09-02 10:03:00 作者:一季烟雨凉

愚蠢,我已经发出了新闻稿,但不检查的链接。其中之一被打破,所以我要处理这htaccess的。

Stupidly, I have sent out a newsletter without checking the links. One of which is broken so I want to handle this with htaccess.

我是被链接到网址为:

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

在实际页面: http://www.domain.com.au/露营者和 - 房车/新西兰/野营-房屋出租/

请注意在新西兰以及附加www.domain.com.au空间

Note the space in new zealand as well as the additional www.domain.com.au

我如何设置这htaccess的?

How can I set this up in htaccess?

感谢

推荐答案

既然你没有操纵URL,你可以使用一个简单的重定向:

Since you don't have to manipulate the URL, you can use a simple 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%,尝试引用整个事情在有一个真实的空间:

Edit If Apache doesn't like the space unquoted as %20, try quoting the whole thing with a real space in there:

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摆脱查询字符串,而不是一个简单的重定向,我害怕。

Edit2 If it's appending a query string, you will need to use mod_rewrite to get rid of the querystring rather than a simple redirect, I'm afraid.

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]
 
精彩推荐
图片推荐