Forum Moderators: phranque

Message Too Old, No Replies

Rewrite an already rewritten value

         

jingram

10:09 am on Dec 31, 2008 (gmt 0)

10+ Year Member



Hello how are you all doing.

I would like to enter an address such as [localhost...] and have it rewritten by mod_rewrite into [localhost...]

I can do this fine with this:

RewriteRule ^Products\.html$ Index.php?Application=Products [L]

So in the browser address bar you will see [localhost...]

However, now I want to send some variables to this application like this: [localhost...] and I want my PHP page Index.php to have access to the variables Application and Message. So the idea is that we request an application (which is called Products) and send to it whatever parameters we want.

The problem is that I want to have the browser only show [localhost...] in the address bar (but still pass the extra parameters).

First, is this possible with my setup?
Second, here is my current attempt to get this to work:

RewriteCond %{QUERY_STRING} (.*)
RewriteRule ^Products\.html$ Index.php?Application=Products&%1 [L]

So this does send the parameters to my application (I have access to them when I need them), but my browser address bar looks messy.

Thank you for any suggestions or improvements. I've researched a fair bit but cannot find a solution.

Jon

Caterham

1:28 pm on Dec 31, 2008 (gmt 0)

10+ Year Member



You can hide the args only, if you pass them statically to your script and not within the URL, i.e.

Index.php?Application=Products&some=othervariable

Otherwise you'd have to think about an URL layout like /producs-Message-TestMessage or whatever, but include the vars into the path instead of the query string.

g1smd

6:13 pm on Dec 31, 2008 (gmt 0)

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



If the new parameters come from a form, you can POST them, and they will not appear in the URL.

jingram

3:15 am on Jan 1, 2009 (gmt 0)

10+ Year Member



A post would probably work with some changes but is not ideal. I'll look into it though. Thanks for the suggestions.