Link to home
Create AccountLog in
Avatar of meno19
meno19

asked on

Help with Writting .htaccess URL Query String ReWrite

I looking to see if I can get some assistance with writing a URL Rewrite.

I have a set of pages that use 2 query strings. How would I write rewrite rules for the .htaccess that handle the converts the query strings to a friendly rewrite url??

Original URL - http://site.com/detail/?n=Pub-&-Brewery&restaurant=3581

Rewrite URL - http://site.com/detail/Pub-&-Brewery/3581/
Avatar of kaufmed
kaufmed
Flag of United States of America image

You're thinking about this backwards. .htaccess takes the "friendly" URLs and turns them into querystring URLs (which is what the server expects). You write the friendly URLs in each of your pages; then you write .htaccess rule(s) to translate those pretty URLs into the ugly URLs (on the server).
Avatar of meno19
meno19

ASKER

Yes you are correct, sorry about flipping the two around. How would I translate the url
http://site.com/detail/Pub-&-Brewery/3581/ into http://site.com/detail/?n=Pub-&-Brewery&restaurant=3581.
I think this would work

RewriteEngine on
RewriteCond http://site.com/detail/Pub-&-Brewery/3581
RewriteRule  http://site.com/detail/?n=Pub-&-Brewery&restaurant=3581

of course that is only good for the 1 url. If you need to do many you will need to do some more work
Avatar of meno19

ASKER

Yes I was looking on how to do this for that format not that specific instance.
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account