2016-08-23 134 views
-2

例如,我有一個網站example.com,它鏈接到example.org中存儲的文件。因此,如果用戶點擊下載(默認鏈接是www.example.org/file.zip),我想將他重定向到第三個域 - example.net。簡而言之: www.example.com已鏈接到www.example.org,但當您單擊它時,您將被重定向到example.net。這可能使用htaccess?如何使用htaccess重定向鏈接?

回答

0

回答你的問題:是的,這是可能的。您的含義很模糊,因此您需要確保自定義以下解決方案以滿足您的真實需求。但重要的它會是這樣的:

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.+)\.zip$ http://example.com/{REQUEST_URI} [L,QSA] 
</IfModule> 
+0

我的意思是,如果我加入www.example.com像這樣的鏈接:到 File我想重定向example.org/file.zip www.example.net – cooher

+0

是的,這正是.htaccess的用途。 [htaccess手冊](https://httpd.apache.org/docs/current/howto/htaccess.html) – mrheroux

+0

好吧,我知道我非常含糊,因爲我的第一語言不是英語。我找到了我想要的: AddOutputFilterByType SUBSTITUTE text/html 替代s/mysite.com/sitename.com/ni 現在我需要將geoIP應用於此代碼。我試圖這樣做: SetEnvIf之後GEOIP_COUNTRY_CODE美國LinkCountry 這裏 #Substitute但它不工作。沒有IfDefine的替代代碼完美工作,geoIP也很好(我已經用env = LinkCountry的拒絕測試了它)。任何想法如何使用If語句? – cooher