homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Apache Mod Rewrite Question

 12:18 am on Jan 16, 2006 (gmt 0)

Hello everyone!
I currently have a URL that looks like:

I would like it to redirect to:

Here is my .htaccess mod rewrite code:
Options +FollowSymLinks
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!



 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]



 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?

Thanks again!


 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].



 5:09 pm on Jan 17, 2006 (gmt 0)

Thank you, will do.


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved