htaccess file to redirect to a script

Hi Everyone

I’m trying to write an .htaccess rule to redirect to a script, which further redirects somewhere else. However, I don’t want the address url to change during the .htaccess part of the redirect.

Example:
test.mytest.com/page/test/hello
this page should be hanlded by test.mytest.com/environment_test.php
but test.mytest.com/page/test/hello still appears in browser.

Thanks for reply in advance

Firstly you need rewrite turned on in apache otherwise nothing will work.

Once that’s done I think this is vaguely what you want (taken from what i use)

RewriteEngine On RewriteCond %{HTTP_HOST} ^test\.mytest\.com [NC] RewriteRule ^([A-Za-z0-9-]+)/?$ $1.php [NC,L]

If you then goto test.mytest.com/thispage/ in your browser, it will load test.mytest.com/thispage.php but still show the original url you input into your browser.

If you need to enable RewriteEngine, try google. I can’t remember how I done that anymore

Sponsor our Newsletter | Privacy Policy | Terms of Service