Forum Moderators: phranque

Message Too Old, No Replies

Hiding redirected URL

         

mramzan

6:45 am on Aug 21, 2008 (gmt 0)

10+ Year Member



HI

I am using mod_rewrite for URL re-writing. I am using apache 2.2 and in the httpd.conf i have the following rule

RewriteRule ^/foo/((.)+)$ /$1 [R=301,L]

Where /((.))+ is evaluated to mymachine.com/myapp?param1=val&param2=value

Problem is that this evaluated URL is shown in the address bar, is there a way in the mod_rewrite that this URL is not shown in the address bar.

Thank in advance

Ramzan

phranque

7:33 am on Aug 21, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld [webmasterworld.com], Ramzan!

you probably want to do in internal rewrite rather than an external redirect.
the R code specifies an external redirect.
try this instead:
RewriteRule ^/foo/((.)+)$ /$1 [L]

mramzan

8:52 am on Aug 21, 2008 (gmt 0)

10+ Year Member



Thank a lot for your reply

I tried it out with simple [L] but it still shows the full URL in the address bar with all the parameters in the query string.

Is there a way that when a re-write rule is evaluated the expanded URL is not shown in the address bar or is shown without query string?

Thanks for help

phranque

9:46 am on Aug 21, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



you should only see a changed url in your address bar if the server returns a 301 or 302 response code.
are there other rewrite rules in the httpd.conf?

mramzan

10:40 am on Aug 21, 2008 (gmt 0)

10+ Year Member



Yes i have another rule which is something like following

RewriteRule ^/foo/secureit/((.)+)$http://localhost:9999/secureapp/resolve?$1 [R=301,L]

RewriteRule ^/foo/((.)+)$ /$1 [R=301,L]

Basically,first my app is redirected to a locally deployed secureapp which returns a URL matching the pattern, ^/foo/((.)+).

When the second rule is evaluated, full URL is displayed in the address bar.

g1smd

7:45 pm on Aug 21, 2008 (gmt 0)

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



If you have rewrites before redirects you will expose the internal filepaths in URLs.

Always place redirects first, and rewrites last.

mramzan

9:46 am on Aug 22, 2008 (gmt 0)

10+ Year Member



Doing so does not make any success.

g1smd

7:00 pm on Aug 22, 2008 (gmt 0)

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



Best post your code here for a debugging...

mramzan

5:38 am on Aug 27, 2008 (gmt 0)

10+ Year Member



Thanks a lot every one, i solved my problem in my code using AJAX