Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
07-06-2009, 06:24 AM
|
#2
|
Senior Member
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,466
Rep:
|
Last edited by your_shadow03; 07-06-2009 at 06:27 AM.
|
|
|
07-06-2009, 06:38 AM
|
#3
|
LQ Newbie
Registered: Jul 2009
Posts: 4
Original Poster
Rep:
|
Quote:
Originally Posted by your_shadow03
|
But when access http://domain1/index.php?something, not redicect?
this cannot be done..
|
|
|
07-06-2009, 06:44 AM
|
#4
|
Senior Member
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,466
Rep:
|
Have you provided the complete path to the page after which you trying to redirect?
It seems you are not providing the complete path.
|
|
|
07-06-2009, 07:17 AM
|
#6
|
LQ Guru
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,230
|
You have to use mod_rewrite in order to be able to redirect such URLs and not Redirect
Code:
RewriteRule ^(.+) http://domain2/$1
Regards
Last edited by bathory; 07-06-2009 at 07:20 AM.
|
|
|
07-06-2009, 07:27 AM
|
#7
|
LQ Newbie
Registered: Jul 2009
Posts: 4
Original Poster
Rep:
|
Quote:
Originally Posted by bathory
You have to use mod_rewrite in order to be able to redirect such URLs and not Redirect
Code:
RewriteRule ^(.+) http://domain2/$1
Regards
|
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...
|
|
|
07-06-2009, 07:29 AM
|
#8
|
Member
Registered: Jan 2002
Location: Labrador, Canada
Distribution: CentOS, Debian
Posts: 182
Rep:
|
Or you can do it with PHP by adding something like this to the top of your index.php file on domain1:
PHP Code:
if (!$_GET) { header ('Location: http://domain2/index.php'); exit; }
|
|
|
07-06-2009, 07:35 AM
|
#9
|
LQ Guru
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,230
|
You didn't say anything about localhost 
Anyway, you have to add a RewriteCond for localhost:
Code:
RewriteCond %{REQUEST_URI} ^localhost/index.php$
RewriteRule ^(.+) http://domain2/index.php
Note that Redirect (uses mod_alias) is different than mod_rewrite
Last edited by bathory; 07-06-2009 at 08:07 AM.
|
|
|
All times are GMT -5. The time now is 05:10 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|