Forum Moderators: phranque

Message Too Old, No Replies

Redirect - why does target have to be full URL

Redirect - why does target have to be full URL

         

HyperWeb

10:30 pm on Feb 2, 2006 (gmt 0)

10+ Year Member



Hi,
I am trying to set up some redirects in my .htaccess file.

On my test server I have been able to get the following to work

redirect /foo.html?test [blah.blah.blah...]

however it fails if I try
redirect /foo.html?test /test/foo.html

why is that so?

the reason I would like the 2nd option to work is so that I can maintain the same .htaccess file on my test and production environment, otherwise I need to have 2 copies.

On test:
redirect /foo.html?test [test.sever.blah...]

On Production:
redirect /foo.html?test [production.sever.blah...]

Am I missing something?
Thanks for your inputs.

kaled

11:37 am on Feb 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can you use environment variables in .htaccess? If yes, this should provide a solution.

Kaled.

HyperWeb

11:11 pm on Feb 9, 2006 (gmt 0)

10+ Year Member



Hi Kaled,
thanks for the reply. Unfortunately I am not quite accomplised in Apache yet.
How would this work? Can you give a few more specifics.
Thanks.

kaled

12:37 am on Feb 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry, I can't help with specifics since I've never needed to delve into this.

The environment variable that might help is SERVER_NAME. There may be a syntax that can be used in .htaccess to insert this after the http://

Try forum92

Kaled.

Dijkgraaf

1:29 am on Feb 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Something like the following might do the trick
redirect /foo.html?test [%{SERVER_NAME}...]