我希望它能显示网址
/index.php?page=somePage&id=someID&siteAddress=someAddress
如
/someAddress/?page=somePage&id=someID
。
如何为此使用重写规则?
答案 0 :(得分:0)
要将 / someAddress 内部重写为 /index.php :
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^page=([^&]+)&id=([^&]+)$
RewriteRule ^/?([^/]+)/$ /index.php?page=%1%id=%2&siteAddress=$1 [L]
要将 /index.php 外部重定向到 / someAddress :
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?page=([^&]+)&id=([^&]+)&siteAddress=(^[&\ ]+)
RewriteRule ^ /%3/?page=%1&id=%2 [L,R=301]