2010-08-18 74 views
9

我從花葯網站的鏈接,我沒有的http://domain.com/one two three.exe的.htaccess對URL重定向與空間在它

控制正確的URL是http://domain.com/one_two_three.exe

注:下劃線代替空格。

我在網上搜索,發現這個代碼片段的.htaccess

# Redirect old file path to new file path 
Redirect /one%20two%20three.exe http://domain.com/one_two_three.exe 

我在文件的頂部添加了這個片段到我的預先存在的根的.htaccess。
但它似乎並不奏效。我的瀏覽器不重定向,我得到一個404錯誤頁面。

我相信它與原始URL中的空格有關,但我不知道如何處理url中的空格。

對此提出建議?

回答

23

你可以嘗試一些事情(包括未經)( - :

Redirect "/one two three.exe" http://domain.com/one_two_three.exe 

或使用RewriteRule代替Redirect

RewriteRule /one\ two\ three.exe http://domain.com/one_two_three.exe 
+1

謝謝,第一個爲我工作 – 2010-08-18 17:46:41

+0

二一個爲我工作,我需要重定向到一個URL中有一個空格「\」完美的作品! – 2013-03-07 16:15:51

+0

不錯的提示 - +1從我:) – Luckyfella 2018-02-22 15:38:45