redirecting to another website

P

pkg

Dear all!

how can I obtain that if somebody calls the website with address
www.mywebsite.de/abc/123.html
he/she is redirected to the website with address with address
www.mywebsite.de/xyz/987.html
??? With "redirected" I mean that automatically the second page is
opened if the first is called.
I should tell you that I am completely new to html ... so I would
appreciate answers adapted to my low level of proficiency in this
stuff!!!

Many thanks!

BR

pkg
 
P

pkg

.... I have just noticed that the site www.mywebsite.de actually
exists! Of course, I meant this to be a dummy name ... it has nothing
to with the actual content on this website!!!
pkg
 
J

J.O. Aho

pkg said:
Dear all!

how can I obtain that if somebody calls the website with address
www.mywebsite.de/abc/123.html
he/she is redirected to the website with address with address
www.mywebsite.de/xyz/987.html
??? With "redirected" I mean that automatically the second page is
opened if the first is called.

There is different ways to do it

1. redirect in the web server config (apache):
Redirect permanent /abc/123.html http://www.mywebsite.de/xyz/987.html

2. Use server side script (php):
<?php header("Location: http://www.mywebsite.de/xyz/987.html"); ?>

3. Use meta tag to redirect:
<META http-equiv="refresh"
content="0;URL=http://www.mywebsite.de/xyz/987.html">

4. Use some javascript to redirect:
<body onload="document.location='http://www.mywebsite.de/xyz/987.html'">

I have listed those in the order in which I would use those, server settings
is best, server side script is second, third is meta tag and last javascript
as people don't always enable it.

I should tell you that I am completely new to html ... so I would
appreciate answers adapted to my low level of proficiency in this
stuff!!!

I hope the examples are easy enough to use.
 
J

J.O. Aho

pkg said:
... I have just noticed that the site www.mywebsite.de actually
exists! Of course, I meant this to be a dummy name ... it has nothing
to with the actual content on this website!!!

For dummy addresses you use example.net or example.com
 
P

pkg

1. redirect in the web server config (apache):
Redirect permanent /abc/123.htmlhttp://www.mywebsite.de/xyz/987.html

Well, I don't want to bother the our webmasters with these things! And
I think they are the only persons who could change the web server
config ...
2. Use server side script (php):
<?php header("Location:http://www.mywebsite.de/xyz/987.html"); ?>

as before
3. Use meta tag to redirect:
<META http-equiv="refresh"
content="0;URL=http://www.mywebsite.de/xyz/987.html">

This sounds as if I could do it without the web admins. Could you give
some more details what you mean? (you know, I have actually no
knowledge!)
4. Use some javascript to redirect:
<body onload="document.location='http://www.mywebsite.de/xyz/987.html'">

Sounds good as well. Please give more details ( I don't "speak" java!)

pkg
 
J

J.O. Aho

pkg said:
Well, I don't want to bother the our webmasters with these things! And
I think they are the only persons who could change the web server
config ...


as before

If php is enabled, then there is nothing to ask the admins, it's just create a
php script and put it on the server in the same way as a html page. The
example is everything you need.

This sounds as if I could do it without the web admins. Could you give
some more details what you mean? (you know, I have actually no
knowledge!)

--- the html page ---
<html>
<head>
<title>redirect</title>
<META http-equiv="refresh"
content="0;URL=http://www.mywebsite.de/xyz/987.html">
</head>
<body>
</body>
</html>
--- eof ---

Sounds good as well. Please give more details ( I don't "speak" java!)

JavaScript isn't Java, just similar names and as I pointed out before, it's
not a good idea, as you will be even less sure about the redirect will happen
than with the meta tag, the php script will ensure you a better reliability
that the redirect has been done.
 
P

pkg

2. Use server side script (php):
If php is enabled, then there is nothing to ask the admins, it's just create a
php script and put it on the server in the same way as a html page. The
example is everything you need.

well ... the first point is that in the directory abc there are more
html files than the metionned 123.html. So I guess if I put this php
script in the resp. directory all sites are redirected, which I do not
intend. Second: For the script, do I have to create a file (how does
it haver to named?) with just
<?php header("Location:http://www.mywebsite.de/xyz/987.html"); ?>
in it? ... sorry, as I said, I hpe I don't sound too dull ...

--- the html page ---
<html>
<head>
<title>redirect</title>
<META http-equiv="refresh"
content="0;URL=http://www.mywebsite.de/xyz/987.html">
</head>
<body>
</body>
</html>
--- eof ---

Perfect! Thanks, it is really easy and works fine! But maybe you can
nevertheless answer the question regarding your php-solution ...
because you say that it's saver.

pkg
 
J

J.O. Aho

pkg said:
well ... the first point is that in the directory abc there are more
html files than the metionned 123.html. So I guess if I put this php
script in the resp. directory all sites are redirected,

You need to create a php script for each page to redirect, and you will most
likely have to tweak with .htaccess (requires the web server uses apache) to
make parse html files as php file.
which I do not
intend. Second: For the script, do I have to create a file (how does
it haver to named?) with just
<?php header("Location:http://www.mywebsite.de/xyz/987.html"); ?>
in it? ... sorry, as I said, I hpe I don't sound too dull ...

Usually a php file is called something like hello.php, but with use of
..htaccess in the directory where you intend to place the php scripts, you
could make it work even if the file was called hello.html.


With your experience it may be better to use the meta tag, it will work in
most cases.
 
P

pkg

With your experience it may be better to use the meta tag, it will work in
most cases.

Yes, for the moment it seems the best solution. Maybe I will try the
php solution again later. In any case, thanks again for your help!

pkg
 
J

John Hosking

pkg said:
Yes, for the moment it seems the best solution. Maybe I will try the
php solution again later. In any case, thanks again for your help!

Not so fast, there. Usually a bunch of folks jump right in when someone
considers using a meta redirect. I guess most folks are asleep or busy
or living a real life right now. So *I'll* speak up. ;-)

There are disadvantages with that method (although it is indeed easy). I
suggest you Google or Yahoo or Dogpile words like "meta redirect". Read
a few of the results. Problems include search engine problems,
accessibility problems, broken Back buttons, and extra traffic. That's
why J.O. Aho correctly recommends the 301 code as the preferred route.

See, for starters, the overview info at
http://en.wikipedia.org/wiki/URL_redirection, as well as
http://en.wikipedia.org/wiki/Meta_refresh (or Google up your own further
research).

Sorry to make an "easy" task harder.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top