Forum Moderators: phranque

Message Too Old, No Replies

Simple RewriteRule help

         

Prasawet

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

10+ Year Member



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]

wilderness

2:04 pm on Feb 13, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Recent thread almost identical [webmasterworld.com]

jdMorgan

9:34 pm on Feb 17, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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

Prasawet

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

10+ Year Member



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!

jdMorgan

4:04 am on Feb 18, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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