Welcome to WebmasterWorld Guest from 3.227.2.109

Forum Moderators: Ocean10000 & phranque

Message Too Old, No Replies

Simple RewriteRule help

     
1:52 pm on Feb 13, 2011 (gmt 0)

New User

5+ Year Member

joined:Dec 7, 2010
posts: 35
votes: 2


I am stuck here...

http//domain.com/1234p should point to itemout.php with ID=1234p.
(no html extension etc).

Try this but not working:

RewriteRule ^/([^/.]*)/([A-Za-z0-9-]+)$ itemout.php?id=$1 [L]
2:04 pm on Feb 13, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member wilderness is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Nov 11, 2001
posts:5507
votes: 5


Recent thread almost identical [webmasterworld.com]
9:34 pm on Feb 17, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


Where are you putting this code? It was apparently written for use in a server configuration file outside of any <Directory> containers. For use in .htaccess, it would need to be changed slightly. As well, a correction is needed to conform to your stated requirement, and a 41% efficiency improvement is possible simply by using [NC]:

# Internally rewrite requests for URL-path /<letters-numbers-hyphens>
# to server filepath /itemout.php?id=<letters-numbers-hyphens>
RewriteRule ^([a-z0-9\-]+)$ itemout.php?id=$1 [NC,L]

Jim
10:20 pm on Feb 17, 2011 (gmt 0)

New User

5+ Year Member

joined:Dec 7, 2010
posts: 35
votes: 2


Yes, it is for use in a server configuration file outside dir.

I solved it with:
    RewriteRule ^(.*)$ itemout.php?xurl=$1[L]


NC
...very useful remark...thanks!
4:04 am on Feb 18, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


If you want to rewrite requests for /foo to /itemout.php?xurl=foo instead of /itemout.php?xurl=/foo then use:

RewriteRule ^/(.*)$ /itemout.php?xurl=$1 [L]

Note also the leading slash on "itemout" and the required space before "[L]"

Jim