2015-11-04 95 views
1

我試圖通過例如:如何通過apache RewriteRule傳遞變量?

www.example.com/quote/20.html 

到:

www.example.com/quote.php?id=20 

mod_rewite是和當前的規則似乎並沒有傳遞變量:

Options +FollowSymLinks 
Options -Indexes 
# STRONG HTACCESS PROTECTION 
<Files ~ "^.*\.([Hh][Tt][Aa])"> 
order allow,deny 
deny from all 
satisfy all 
</Files> 


RewriteEngine on 

RewriteRule quote/(.*).html quote.php?id=$1 

RewriteRule topic/(.*)/(.*).html topic.php?topic=$1&page=$2 

回答

1

嘗試如下:

Options +FollowSymLinks -Indexes -MultiViews 
# STRONG HTACCESS PROTECTION 
<FilesMatch "\.(?i:htaccess)$"> 
    Order allow,deny 
    Deny from all 
    Satisfy all 
</FilesMatch> 

RewriteEngine On 

RewriteCond %{THE_REQUEST} ^GET\ /quote\.php\?id=(\d+) [NC] 
RewriteRule ^quote\.php$ /quote/%1? [R=301,L,NC] 

RewriteRule ^quote/(\d+).html$ /quote.php?id=$1 [L] 
RewriteRule ^topic/([^/]+)/(.+).html$ /topic.php?topic=$1&page=$2 [L] 
+0

當我將上面的部分更改爲「RewriteEngine On」時,出現500內部錯誤。我改變了所有其餘的,但仍然沒有進展。 – Tom

+0

它在錯誤日誌中說什麼? – hjpotter92

+0

「.htaccess:預計但看到」 – Tom