Helmet Posted April 6, 2009 Share Posted April 6, 2009 It is possible to rewrite something like example.com/index.php?foo=bar&foo2=bar2&foo3=bar3&foo4=bar4 to something like example.com/bar/bar2/?foo3=bar3&foo4=bar4 I've tried with this but the page is not found: RewriteRule ^(.*)/(.*)/\?foo3=$3&foo4=$4$ index.php?foo=$1&foo2=$2&foo3=$3&foo4=$4 Thanks in advance, Helm Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted April 6, 2009 Share Posted April 6, 2009 yes if you set the QSA flag RewriteRule ^(.*)/(.*)/ index.php?foo=$1&foo2=$2 [L,QSA] Quote Link to comment Share on other sites More sharing options...
Helmet Posted April 6, 2009 Author Share Posted April 6, 2009 Thanks for your reply, but adding the QSA flag still results in a 404. I'm trying to convert half of the querystring to directory structure, and keep the other half as query string. So I guess my example should have been more like: RewriteRule ^(.*)/(.*)/\?foo3=(.*)&foo4=(.*)$ index.php?foo=$1&foo2=$2&foo3=$3&foo4=$4 [L,QSA] Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted April 6, 2009 Share Posted April 6, 2009 No. You don't need to specify the query string within your rewriteRule. All you need to do is specify the bits you're rewriting. So if you url is like this: example.com/bar/bar2/?foo3=bar3&foo4=bar4 You just need to setup your rewriteRule to match the bits highlighted above. Which is what the following rewriteRule does. RewriteRule ^(.*)/(.*)/ index.php?foo=$1&foo2=$2 [L,QSA] I have tested this and it works fine for me. Quote Link to comment Share on other sites More sharing options...
Helmet Posted April 6, 2009 Author Share Posted April 6, 2009 Wow.. I was further off track than I thought. Thanks, worked nicely with this: RewriteRule ^(.*)/(.*)/$ index.php?foo=$1&foo2=$2 [L,QSA] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.