Krystine
10-09-2007, 06:53 PM
Is there a way to use mod_rewrite to rewrite an url from
from:
http://www.example.com/foo/bar/baz/qux/quux/corge+grault/
http://www.example.com/foo/bar/baz/qux/quux/corge+grault
to:
http://www.example.com/index.php?a=foo&b=bar&c=baz&d=qux&e=quux&f=corge+grault
I have
Options +FollowSymLinks
RewriteEngine on
RewriteEngine on
RewriteBase /
RewriteRule (.*)/(.*)-(.*)$ index.php?user=$1&cat=$2&mode=$3
RewriteRule (.*)/(.*)$ index.php?user=$1&cat=$2&mode=$3
which works fine if I only have two variables I want to pass to my script (or three if I don't mind breaking my format slightly). I want to use the forward slash ("/") as the delimiter for variables.
I can potentially process the url uses regex and pathname() in php if I can get apache to redirect to
http://www.example.com/index.php?query=foo/bar/baz/qux/quux/corge+grault/
http://www.example.com/index.php?query=foo/bar/baz/qux/quux/corge+grault
(but I would rather use htaccess to rewrite the requests as a GET request).
from:
http://www.example.com/foo/bar/baz/qux/quux/corge+grault/
http://www.example.com/foo/bar/baz/qux/quux/corge+grault
to:
http://www.example.com/index.php?a=foo&b=bar&c=baz&d=qux&e=quux&f=corge+grault
I have
Options +FollowSymLinks
RewriteEngine on
RewriteEngine on
RewriteBase /
RewriteRule (.*)/(.*)-(.*)$ index.php?user=$1&cat=$2&mode=$3
RewriteRule (.*)/(.*)$ index.php?user=$1&cat=$2&mode=$3
which works fine if I only have two variables I want to pass to my script (or three if I don't mind breaking my format slightly). I want to use the forward slash ("/") as the delimiter for variables.
I can potentially process the url uses regex and pathname() in php if I can get apache to redirect to
http://www.example.com/index.php?query=foo/bar/baz/qux/quux/corge+grault/
http://www.example.com/index.php?query=foo/bar/baz/qux/quux/corge+grault
(but I would rather use htaccess to rewrite the requests as a GET request).