Home htaccess rewrite general help for the helpless
Reply: 1

htaccess rewrite general help for the helpless

lexguru
1#
lexguru Published in 2018-02-13 06:32:14Z

I'm completely helpless when it comes to htaccess. I've tried and tried and can't seem to understand it.

I'm trying to rewrite

http://somedomainname.com/index.php?route=product&make=Samsung&model=1001SHD

to the link below

http://somedomainname.com/Samsung-1001SHD-TV-Set

The TV-Set would be a static addition to each URL. It will be the same across the entire site.

Any tips, pointers, code, or a finger in the right direction would be very much appreciated it.

Thanks

anubhava
2#
anubhava Reply to 2018-02-13 08:37:21Z

You can use these rule in your site root .htaccess:

RewriteEngine On

# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} /index\.php\?route=product&make=([^\s&]+)&model=([^\s&]+) [NC]
RewriteRule ^ /%1-%2-TV-Set? [R=301,L,NE]

# internal forward from pretty URL to actual one
RewriteRule ^([^-]+)-([^-]+)-TV-Set/?$ index.php?route=product&make=$1&model=$2 [L,QSA,NC]
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.385033 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO