Double Parameter URL Rewrite

2019-09-13 01:30发布

I have the following URL with double parameters and for the first time would like to do double parameter rewrite.

My URL: http://localhost/b2b/post?post_id=1&post_subject=test

I'd like to rewrite it to: http://localhost/b2b/post/post_id/1/post_subject/test

My .htaccess is:

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>

标签: php url rewrite
1条回答
SAY GOODBYE
2楼-- · 2019-09-13 01:46

You should just write :

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]
查看更多
登录 后发表回答