Gabriel Silva Gabriel Silva - 2 months ago 18
Apache Configuration Question

htaccess with multi-parameters

I'm trying to redirect my links like this:

my href =

example.com/?p=users&page=2


my URL should be =
example.com/users/page/2


At this moment, my mod_rewrite is working with:

my href =
example.com/?p=users


my URL =
example.com/users


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>

Answer

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]