2012-09-05 93 views
0

如何在URL「.php」或「.html」或「?」時使用.htaccess重定向頁面。或「=」?使用重定向頁面。 htaccess

Examples 
http://www.domain.ltd/index.php  # error, execute redirect to http://www.domain.ltd/ban/ 
http://www.domain.ltd/index/?id=foo # error, execute redirect to http://www.domain.ltd/ban/ 
http://www.domain.ltd/index.html # error, execute redirect to http://www.domain.ltd/ban/ 

非常感謝您

回答

0

取自段:http://www.webconfs.com/how-to-redirect-a-webpage.php

Options +FollowSymlinks 
RewriteEngine on 
rewritecond %{http_host} ^domain.com [nc] 
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc] 

顯然與你的頁面替換domain.com。此重定向將查看任何來自domain.com的內容並將其轉發至www.domain.com。

一個快速的Google爲我製作了這個漂亮的htaccess生成器(但我現在不能發佈)。

+1

但它沒有回答我的問題:-( – Charlie

+0

請嘗試以下操作,您可能需要玩它重定向到的位置:RewriteRule^index \ .php $/ban [NC,R] –