我正在尝试像这样重定向我的链接:
my href = example.com/?p=users&page=2
我的网址应该是 = example.com/users/page/2
此时,我的 mod_rewrite 正在处理:
my href = example.com/?p=users
我的网址 = example.com/users
这是我的 htaccess:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/index.php
RewriteRule ^(.*)$ index.php?p=$1 [L,QSA]
</IfModule>
最佳答案
完整的 .htaccess 如下:
Options +FollowSymLinks
RewriteEngine On
# skip all files and directories from rules below
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# skip index.php from any rules below
RewriteRule ^index\.php$ - [L,NC]
# handle /users/page/2 URI
RewriteRule ^([\w-]+)/([\w-]+)/(\d+)/?$ index.php?p=$1&$2=$3 [L,QSA]
# handle /users URI
RewriteRule ^([\w-]+)/?$ index.php?p=$1 [L,QSA]
关于apache - 具有多参数的 htaccess,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39516329/