HTACCESS友好的url并允许GET方法

MM *_* PP 3 php apache url .htaccess seo

我的代码是

 Options -Multiviews

 RewriteEngine On
 RewriteBase /

 RewriteRule ^([a-z0-9-]+)\.html$ /index.php?cat=$1 [L]
Run Code Online (Sandbox Code Playgroud)

如果我访问

mysite.com/name-of-category.html 
Run Code Online (Sandbox Code Playgroud)

它工作,但如果我访问

mysite.com/name-of-category.html?anything=something
Run Code Online (Sandbox Code Playgroud)

它显示了网页但$_GET["anything"]没有显示任何内容.

小智 5

您必须指定一个名为QSA或'Query String Append'的选项:

RewriteRule ^([a-z0-9-]+)\.html$ /index.php?cat=$1 [L,QSA]
Run Code Online (Sandbox Code Playgroud)

它将确保原始查询字符串也包含在新URL中.