user2330401
user2330401

Reputation: 173

Htaccess rewriting multiple variables

I am completely dumb when it comes to .htaccess, even through my numerous attempts to learn the basics. So I am here:

This is my current .htaccess:

RewriteEngine on
RewriteRule ^$ /splash [L,R=301]
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
RewriteRule ^([a-z0-9-]+)/?$ /index.php?cat=$1 [L,NC,QSA]

I would like to keep its current functionality and add two things so its like:

Upvotes: 1

Views: 75

Answers (1)

anubhava
anubhava

Reputation: 786289

You can use:

RewriteEngine on
RewriteRule ^$ /splash [L,R=301]

RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \s(.+?)/+[?\s]
RewriteRule ^(.+?)/$ /$1 [R=301,L]

RewriteRule ^([a-z0-9-]+)/?$ /index.php?cat=$1 [L,NC,QSA]

RewriteRule ^([a-z0-9-]+)/([a-z0-9-]+)/?$ /index.php?cat=$1&product=$2 [L,NC,QSA]

Upvotes: 2

Related Questions