Welcome to WebmasterWorld Guest from 220.127.116.11 , register , free tools , login , search , subscribe , help , library , announcements , recent posts , open posts Accredited PayPal World Seller
Apache Mod Rewrite Question kodaks msg:1495974 12:18 am on Jan 16, 2006 (gmt 0) 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!
jdMorgan msg:1495975 5:34 pm on Jan 16, 2006 (gmt 0)
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 msg:1495976 7:51 pm on Jan 16, 2006 (gmt 0)
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?
jdMorgan msg:1495977 3:19 pm on Jan 17, 2006 (gmt 0)
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].
kodaks msg:1495978 5:09 pm on Jan 17, 2006 (gmt 0)
Thank you, will do.