2015-11-04 102 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