tags:

views:

48

answers:

3

Ok, have a client that has existing links coming in from searchmarketing. I am in process of migrating the program from Cold Fusion to PHP.

RewriteEngine on
RewriteRule ^cat_ap~([^~]+)~(.*)\.htm$ /urban/cat_ap.php?$1=$2 [R]

Currently I have a URL structure:

http://www.test.com/urban/cat_ap~nid~5964.htm

which the above rewrite rule changes to

http://www.test.com/urban/cat_ap.php?nid=5964

Now I want to be able to get the variables out of the query string but maintain the url in the browser to the original http://www.test.com/urban/cat_ap~nid~5964.htm but still have it go to the PHP page.

So that when someone goes to http://www.test.com/urban/cat_ap~nid~5964.htm it actually goes to http://www.test.com/urban/cat_ap.php?nid=5964 but still shows http://www.test.com/urban/cat_ap~nid~5964.htm.

Any ideas on how to do this?

Thanks

Mike

A: 

You are already doing this on this line (but change the R flag to L):

RewriteRule ^/urban/cat_ap~([^~]+)~(.*).htm$ /urban/cat_ap.php?$1=$2 [L]

The URL that the user hits will still show as the .htm version while the server processes it as the .php

random
The R flag redirects the user to the new URL. Additionally, I think $1 in the original RewriteRule would be the name of the variable name, whereas your revised RewriteRule sets this to be a value. Mike specifies the example of nid=5964
alastairs
A: 

The R flag explicitly induces an external redirect. So just remove the R flag.

Gumbo
A: 

I think you'll need to set up reverse proxying to achieve the desired behaviour, and use the P flag with your rewrite rules. I've used a site with this sort of configuration before, so can say that it works, but I'm afraid I've never configured it myself :-(

A good first step at least would be to install mod_proxy and get it loaded and running. The mod_rewrite cookbook page on the P flag has a small amount of detail on proxying RewriteRules, and links through to the ProxyPassReverse directive documentation at apache.org.

alastairs