我有以下带双参数的URL,并且第一次想要进行双参数重写。
我的网址:http://localhost/b2b/post?post_id=1&post_subject=test
我想将其重写为:http://localhost/b2b/post/post_id/1/post_subject/test
我的.htaccess是:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
<Files ~ "^(.*)\.(inc|tpl|sql)$">
Order deny,allow
Deny from all
</Files>
答案 0 :(得分:0)
你应该写:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^post/([a-z0-9-_]+)/([a-z0-9-_]+)/([a-z0-9-_]+)/([a-z0-9-_]+)$ /post.php?$1=$2&$3=$4 [L]