Welcome to WebmasterWorld Guest from 184.108.40.206 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Pubcon Platinum Sponsor 2014
Apache Mod Rewrite Question kodaks
Hello everyone! I currently have a URL that looks like: http://www.example.com/forumdisplay.php?fid=n&sortby=n&order=n&datecut=n
I would like it to redirect to:
Here is my .htaccess mod rewrite code:
RewriteEngine on RewriteRule forum(.*)-sortby(.*)-order(.*)-datecut(.*).html forumdisplay.php?fid=$1&sortby=$2&order=$3&datecut=$4
How do I make the above rewrite rule redirect automatically?
I have searched, but could not find an answer relevant to my question.
Thanks, I really appreciate anybodys help!
The code you posted does the opposite of your atated goal, so this is a bit confusing. What, in the end, are you trying to accomplish? If you're trying to convert your site to use 'search-engine friendly' static URLs, then you code is correct, but you also need to change the links on your pages to 'friendly' form as well -- mod_rewrite is only half of the job.
Also, if that's the case, the followning modification will amke your code more efficient:
RewriteRule ^forum([^-]+)-sortby([^-]+)-order([^-]+)-datecut([^.]+)\.html$ /forumdisplay.php?fid=$1&sortby=$2&order=$3&datecut=$4 [L] Jim kodaks
Thank you very much for your reply!
Yes, I am trying to make search-engine-friendly URL's. Could you please tell me what the difference is between [L] and [R] for mod_rewrites?
The two flags [L] and [R] are unrelated in function, so there is no 'difference' per se.
Have a read through the documents cited in our
forum charter [ webmasterworld.com] -- You'll need that basic foundation to use mod_rewrite and regular expressions successfully. Also, there are some good posts in the Apache forum section of the WebmasterWorld library [ webmasterworld.com].
Thank you, will do.