如何使用 apache RewriteRule 传递变量?
How to pass variable with an 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=
RewriteRule topic/(.*)/(.*).html topic.php?topic=&page=
尝试以下操作:
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= [L]
RewriteRule ^topic/([^/]+)/(.+).html$ /topic.php?topic=&page= [L]
我想通过例如:
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=
RewriteRule topic/(.*)/(.*).html topic.php?topic=&page=
尝试以下操作:
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= [L]
RewriteRule ^topic/([^/]+)/(.+).html$ /topic.php?topic=&page= [L]