RewriteEngine on
RewriteRule ^/?test\.html$ test.php [L]
RewriteRule ^/?([a-zA-Z_]+)/([a-zA-Z_]+)/([a-zA-Z_]+)$ display.php?country=$1&state=$2&city=$3 [L]
According to the tutorial i am using this will render the following http://www.example.com/USA/California/San_Diego yet on my host it doesn't; it simply displays the query string filled url. mod_rewrite is enabled and the first rewrite rule also works so i'm stumped about why this isn't working.
Am i correct in saying that if i access a link that has display.php?country=USA&country=California&city=San_Diego as an href value; i will be redirected to http://www.example.com/USA/California/San_Diego ?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Ah thanks; i think that is my problem with understanding how mod_rewrite and rewrite rules work; i thought they redirected instead of rewriting. I'll try accessing the url as suggested and see what happens
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
That's an error in your regex - though at first glance I can't see what the problem is. Try taking out the ? at the beginning. It might be best to find an online regex checker so you can get the regex nailed down easily.
How did you ensure your images loaded correctly from index.php?
I am trying this clean url method, and while it is loading the include files correct, it is not loading the images, as it thinks they are in:
test.local/pages/selector/images/test.jpg
Rather than: test.local/images/test.jpg.
If I run it with the full URL it is fine, but when in Firefox I right click and View Image, it thinks it's in that long URL.
How do you resolve that?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.