Click to See Complete Forum and Search --> : I need a redirection script? or ...
_LOBO_
08-29-2003, 03:55 AM
I have 2 domains www.test1.com and www.test2.com I want to use the same server space for this 2 websites for example if a write in my browser www.test1.com I want to go at www.test1.com/page1/index.html and if I write www.test2.com I want to go at www.test1.com/page2/index.html I hope this make sense, I heard that this is possible to do with PHP and a redirection page, someone can show me how? And post some links where I can find this script?
Thanks in advance.
_LOBO_
You can send pages to a new location with the header() (http://us4.php.net/manual/en/function.header.php)...
I use JavaScript for this:
<script language="JavaScript">
document.location="http://www.test1.com/page1/index.html";
</script>
A couple of things to point out:
1: 13% (http://www.thecounter.com/stats/2003/May/javas.php) of web users have JavaScript disabled. This will leave those uses stranded on your page, unless you provide an alternate link. PHP will work for everyone. Alternately, you could use a meta refresh in the <head>:
<meta http-equiv="refresh" content="0;url=somepage.htm">
2: the language attribute has been depreciated. A javascript tag should look like this:
<script type="text/javascript">
3: using document.location will not work for frames (it will only forward the single frame). I'd choose one of these, which will keep it working even if frames are used:
window.location.href
top.location.href
Guess, im old fasion :rolleyes: .
Thats why im trying to learn php :cool:
Originally posted by deep
trying to learn phpGood move... :)
_LOBO_
09-01-2003, 02:33 AM
Thanks for your replies!
But maybe I was not really clear, my fault sorry :(.
you explain me how to make/ use redirection pages but, if a write www.test1.com this redirection will search index.html in the web server (root) right?, and the same thing for www.test2.com so the main problem is how you can have 2 websites using the same web space (and diferent domain names). It’s possible to make a script that can detect if you wrote test1.com or test2.com? And that can send you to the correct index.html?
Thanks in advance, and if is not to much ask can you post some examples or links.
Having two domains share the same server space isn't done with PHP, but rather directly through the server. Talk to your server admin. about it, to see if they support that.
_LOBO_
09-03-2003, 07:45 AM
I call my HOST CENTER they tell me that we can do that using HT acces file but I don't have clue how to do that, they send me this example.
Options +Indexes
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
# Rewrite Rule for domain.com
RewriteCond %{HTTP_HOST} domain.com$
RewriteCond %{REQUEST_URI} !ordnername/
RewriteRule ^(.*)$ ordnername/$1
and I ask him how I can change the script to my needs but, they don't really know, can you give a hand with this?
Thanks in advance Piro :)
_LOBO_
09-03-2003, 08:22 AM
I read that i can achive this with this script can you Pyro tell me if this is right.
---------------------CODE----------------------
ORIGINAL
# redirect domain2.com to subdir
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} domain2.com
RewriteCond %{REQUEST_URI} !subdir/
RewriteRule ^(.*)$ subdir/$1 [L]
MY CHANGES
# redirect test1.com to subdir <--I change here (I think subdir can be changed to my needs right?)
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} test1.com <--I change here
RewriteCond %{REQUEST_URI} !subdir/
RewriteRule ^(.*)$ subdir/$1 [L]
# redirect test2.com to subdir2 <--I change here
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} test2.com <--I change here
RewriteCond %{REQUEST_URI} !subdir2/ <--I change here
RewriteRule ^(.*)$ subdir2/$1 [L] <--I change here
-------------------end CODE------------------------
And so for the add more domains this is right?
I'm not too framiliar with .htaccess, so you'd probably be best posting the question in the General section...
_LOBO_
09-04-2003, 02:30 AM
ok thank you anyway.