Forum Moderators: phranque

Message Too Old, No Replies

Simple mod rewrite help needed

         

zoltan

10:10 am on Feb 18, 2008 (gmt 0)

10+ Year Member



I have this linking structure:

myurl.com/scrip.php?a=b&c=d&....x=y

What I would like is to simply rewrite the query string and present the URL like this:

myurl.com/scrip.php/a/b/c/d/..../x/y/

How do I write the rule for this?

Thanks in advance.

Zoltan

gergoe

10:26 pm on Feb 18, 2008 (gmt 0)

10+ Year Member



Zoltán,

You could try this in you .htaccess file:

RewriteEngine On 
Options +FollowSymLinks
#
# Stop going further if the "anything" before the first slash is a directory.
# Skip this check if we did it already. You may want to add other exceptions.

RewriteCond %{ENV:REC_TRANS} !.
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^([^/]+)(/¦$) - [L]
#
# Check that the requested file exists, but only if REC_TRANS is not set,
# otherwise skip this check

RewriteCond %{ENV:REC_TRANS} . [OR]
RewriteCond %{DOCUMENT_ROOT}/$1 -f
#
# Rewrite /name/value/ pathnames into the query string, set REC_TRANS
# environmental variable, and restart parsing of (all) the RewriteRules

RewriteRule ^([^/]+)(/.+)?/([^/]+)/([^/]+)/?$ /$1$2?$3=$4 [QSA,E=REC_TRANS:1,N]

You may want to check this thread [webmasterworld.com] as well, it contains some information about the impact of this recursion, and also has an alternative way of solving your problem.

p.s.: Don't forget to change the broken pipe characters (¦) into solid pipes before using these rules.