homepage Welcome to WebmasterWorld Guest from 54.227.25.58
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

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
iProgram




msg:1521633
 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

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

But it does not work at all :(

 

DrDoc




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

Maybe there's an error on a previous line?

jdMorgan




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

iProgram,

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]

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

Introduction to mod_rewrite [webmasterworld.com]

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

iProgram




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

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

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