带有多参数的htaccess [英] htaccess with multi-parameters

查看:180
本文介绍了带有多参数的htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试这样重定向我的链接:

I'm trying to redirect my links like this:

我的href = example.com/?p=users&page=2
我的网址应为example.com/users/page/2

my href = example.com/?p=users&page=2
my URL should be = example.com/users/page/2

此刻,我的mod_rewrite正在使用:

At this moment, my mod_rewrite is working with:

我的href = example.com/?p=users
我的网址= example.com/users

my href = example.com/?p=users
my URL = example.com/users

这是我的htaccess:

Here is my 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设置为:

Have your complete .htaccess as this:

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]

这篇关于带有多参数的htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆