我正在尝试处理的网站是http://northidahocvma.org/2GD/index.php?page=1
假设我有带有查询字符串参数的URL,如下所示:
/index.php?page=1
使用mod_rewrite,如何将它们重定向到这些URL?
/page/1
或/1/
我得到了这段代码,但仍然无法弄清楚
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+index\.php\?page=([^\s&]+) [NC]
RewriteRule ^ /page/%1? [R=302,L]
RewriteRule ^page/([^/.]+)/?$ /index.php?page=$1 [L,QSA,NC]
答案 0 :(得分:0)
将此代码放入DOCUMENT_ROOT/.htaccess
文件中:
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+index\.php\?page=([^\s&]+) [NC]
RewriteRule ^ /page/%1? [R=302,L]
RewriteRule ^page/([^/.]+)/?$ /index.php?page=$1 [L,QSA,NC]