2010-04-29 75 views

回答

1

檢查你的Apache安裝已啓用的mod_rewrite。

最簡單的形式,規則來完成你想要做的是什麼:

在你的.htaccess

Options +FollowSymLinks 
RewriteEngine on 
RewriteCond %{HTTP_HOST} ^mysite.com$ 
RewriteRule ^/?$ http://mysite.com [R=301,L] 

RewriteRule songs/(.*)/(.*)$ songs/index.php?name=$1&song=$2 

但不妨一讀的Apache文檔http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html以及驗證你的配置,在這裏你會發現一些有用的東西http://perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/#redirects

希望有所幫助。

+0

感謝,但此舉引起當我去「mysite.com」 – 2010-04-30 00:56:39

+0

嘗試刪除此行RewriteRule^/?$ http://mysite.com [R = 301,L] – falomir 2010-04-30 03:36:50

0
RewriteEngine On 

RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
     RewriteRule ^([\d\w]+)/([\d\w]+)$ test.php?name=$1&song=$2 [L] 
+0

我不能讓它工作:( – 2010-04-30 01:15:03

0
RewriteEngine On 
RewriteRule ^/songs/([\d\w\-]+)/([\d\w\-]+)$ test.php?name=$1&song=$2 [L] 

有時它有助於有日誌功能:「此網頁有重定向循環」

RewriteLogLevel 4 
RewriteLog /home/www/mysite.com/log/rewrite.log