我不知道如何用htaccess重写get参数。
这是到目前为止我的htaccess(只删除index.php)。
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www'.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
我想将下面的url http://example.com/?lang=en&dscroll=1200重写为http://example.com/en/dscroll/1200。一些htaccess主,请:)?
谢谢
您的规则不会删除index.php,它只会重定向到没有www
的主机。
对于另一个重写,您需要2。首先,你需要确保你所有内容中的链接看起来像这样:
http://example.com/en/dscroll/1200
而不是包含查询字符串的
然后你需要添加,在你已经有的规则下面,这2条规则:
RewriteCond %{THE_REQUEST} ' /+'?lang=([^&]+)&([^=&' ]+)=([^&' ]+)
RewriteRule ^ /%1/%2/%3? [L,R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ /?lang=$1&$2=$3 [L,QSA]