Garo
Garo

Reputation: 55

Rewrite second URL Parameter htaccess

I have searched in SO but never came across this specific answer. If anyone can help.

This use to be my URL structure /index.php?param1=is1 and I got it to look like this /is1 by using this Rewrite.

RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(index\.php)?\?([^&\ ]+)
RewriteRule ^ /%1? [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?$1 [L]

Do not ask my how I got this as it's been a while that this was written. Now the issue is i have a second parameter. So my url that is like this /index.php?param1=is1&param2=is2 needs to be like this /is1/is2.

Obviously, now it's like this /is1&param2=is2. So i guess what I am searching for is a way to ask if &param2= is seen than hide it ?

I really don't get the logic behind all this URLREWRITE. I am trying to clean my URL structure for SEO purposes and COPY/PASTE logic as URL's should be shared between different users / clients. Obviously, having /this-is-something&this=that is not that bad but having /this-is-something/that is much better.

Just for info, first parameters is BRANDS /this-is-my-brand1 or /this-is-my-brand2 and second parameter is a product as /this-is-my-brand1/product1 before all that I use to have /index.php?brand=brand-one&product=product-one. Changing everything is not an issue, I can start from scratch if there is anything better than what I have.

I am on the learning curve, so I don't mind long explanations.

Any help is appreciated.

Upvotes: 1

Views: 31

Answers (1)

R. Martin
R. Martin

Reputation: 411

If your request parameters name are static (never change) you can use a more specifiq rule

RewriteRule  ^(.+)/(.+)$  index.php?brand=$1&product=$2 [L]

Upvotes: 0

Related Questions