Click to See Complete Forum and Search --> : [RESOLVED] redirect while masking the URL?


mechphisto
08-05-2011, 09:08 AM
I'm trying to set up a redirect rule so that URL 1 redirects to URL 2 (on same server) but the browser's URL bar still reflects URL 1.

Example:
I want browser requests for:
http://www.girlscoutsmoheartland.org/su
(as well as http://www.girlscoutsmoheartland.org/su?su=x )

to redirect to:
http://www.girlscoutsmoheartland.org/pages/suinfo.php
(or http://www.girlscoutsmoheartland.org/pages/suinfo.php?su=x)

but the URL bar to stay saying:
http://www.girlscoutsmoheartland.org/su

Now, I've actually got the redirect part working fine. But anything I try regarding the masking part just throws a 500 (or even a 404) error.

One of the examples I tried:
RewriteRule ^/su(.*)$ http://www.girlscoutsmoheartland.org/pages/suinfo.php$1 [P,L]

and I've tried various combinations of:
^/su$
^/su(*)$
^/su*$
and...
[P,L]
[R=301,L]

What am I doing wrong? I appreciate any help! :)

svidgen
08-05-2011, 10:03 AM
Pretty sure this should suffice:

RewriteRule ^su$ pages/suinfo.php [L,QSA]

The QSA option should take care of the query, so long as the same query variables are used.

svidgen
08-05-2011, 10:10 AM
Sorry, a few more notes. If you're doing this in .htaccess, make sure you have permission in that directly for URL rewriting. Make sure you're turning it on:
RewriteEngine On

And make sure you have the correct base path set. Maybe ...
RewriteBase /~username

mechphisto
08-05-2011, 10:12 AM
Pretty sure this should suffice:

RewriteRule ^su$ pages/suinfo.php [L,QSA]

The QSA option should take care of the query, so long as the same query variables are used.

OMG That's it!! Huzzah! Thank you so much! :D