Need help about redirect of apache!
Hi ,all
How can apache do this: When access http://domain1/index.php , apache redirect to http://domain2/index.php ? But when access http://domain1/index.php?something, not redicect? only use .htaccess. Thanks. |
|
Quote:
this cannot be done.. |
Have you provided the complete path to the page after which you trying to redirect?
It seems you are not providing the complete path. |
Quote:
but when access http://domain1/index.php?something , not redirect. here something stands for sth like 'key=a'. In my .htaccess: RewriteEngine on RedirectMatch 301 ^/index.php$ http://domain2/index.php but when I access 'http://domain1/index.php?key=a', it redirects to http://domain2/index.php too.. |
You have to use mod_rewrite in order to be able to redirect such URLs and not Redirect
Code:
RewriteRule ^(.+) http://domain2/$1 |
Quote:
I do enabled mod_rewrite. I use your code, but when I access http://localhost/index.php?key=1 ,it goes to domain2 again. what I want is when access and only access 'http://localhost/index.php', it redirect to 'http://domain2/index.php', any other urls like 'http://localhost/index.php?key=1' ,do not redirect. Thanks a lot, I've tried all day, almost freak... |
Or you can do it with PHP by adding something like this to the top of your index.php file on domain1:
PHP Code:
|
You didn't say anything about localhost ;)
Anyway, you have to add a RewriteCond for localhost: Code:
RewriteCond %{REQUEST_URI} ^localhost/index.php$ |
All times are GMT -5. The time now is 05:27 AM. |