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

Help:mod_rewrite: /directory/ --> /page.php?id=directory does not work
RewriteRule of directory

 3:16 pm on Mar 22, 2003 (gmt 0)

I have successfully used .htaccess file to rewrite www.mysite.com/info-123.html to www.mysite.com/showinfo.php?id=123

Now I want to rewrite directory, for example:
www.mysite.com/sth/aaa/xyz-info-123.html to www.mysite.com/showinfo.php?dir=aaa&name=xyz&id=123

I use the following rewrite rule to make a test:

RewriteRule ^/NetTools$ /test.php?target=3
RewriteRule ^/NetTools/Messengers$ /test.php?target=34

RewriteRule /directory/([0-9]+) /dbase.php?id=$1

But it does not work at all :(



 3:24 pm on Mar 22, 2003 (gmt 0)

Maybe there's an error on a previous line?


 3:24 pm on Mar 22, 2003 (gmt 0)


In an .htaccess context, do not use a preceding slash on your patterns. Also, do not use an end anchor ($) unless you wish to rewrite only requests which have no trailing slash or further path info appended.

RewriteRule ^NetTools /test.php?target=3 [L]
RewriteRule ^NetTools/Messengers /test.php?target=34 [L]

RewriteRule directory/([0-9]+) /dbase.php?id=$1 [L]

Introduction to mod_rewrite [webmasterworld.com]

<added>Also, use the [L] flag unless you have a good reason not to.</added>


 3:30 pm on Mar 22, 2003 (gmt 0)

Thank you jdMorgan. It works now:)
<Owner Edit>
Another useful link about this:

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