website redirections question?

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
There's a bunch of ways. The most transparent is the Location: http header. To do that you either need to be able to tell your web server to do the redirection or you need to write a page in a server side language like php or jsp.

You can also embed it into your html with a tag like the following:

<meta http-equiv="refresh" content="?;URL=http://www.test.com/gallery"/>

where ? is the number of seconds to wait before redirection. I suppose you could substitute "Location" for "refresh" since http-equiv is meant to be interpreted as an http header. I'm just going on examples I've seen though, so I don't know how well a browser would handle that. That meta tag goes in the <head></head> section, btw.

So, if you have further questions, please specify a bit about your hosting environment (server, any languages available....)
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Originally posted by: Modeps
simple javascript my good mate:

<script>
document.location.href="http://www.test.com/gallery/";
</script>

Not such a great idea. This leaves the original url on the IE's location stack so if the user hits "Back" they get sent to http://test.com/ which sends them back to http://www.test.com/gallery. Firefox seems to be smart enough to do it properly though.

If you want to use javascript

document.location.replace("http://www.test.com/gallery");

should work properly.
 

Mayfriday0529

Diamond Member
Sep 15, 2003
7,187
0
71
Originally posted by: kamper
There's a bunch of ways. The most transparent is the Location: http header. To do that you either need to be able to tell your web server to do the redirection or you need to write a page in a server side language like php or jsp.

You can also embed it into your html with a tag like the following:

<meta http-equiv="refresh" content="?;URL=http://www.test.com/gallery"/>

where ? is the number of seconds to wait before redirection. I suppose you could substitute "Location" for "refresh" since http-equiv is meant to be interpreted as an http header. I'm just going on examples I've seen though, so I don't know how well a browser would handle that. That meta tag goes in the <head></head> section, btw.

So, if you have further questions, please specify a bit about your hosting environment (server, any languages available....)

Site is hosted by 1and1.com they do have php.
I could always change it on the control panel on there website by changing the default local root folder to the /gallery/ folder but in my gallery folder I already have running the coppermine gallery software and it doesn?t seem to like being located in the local root directory or it fails, at least that?s what I got when I tried to install it on the local root.

So if I change it by using my host options I don?t want to mess it up, I thought maybe just redirecting it by some html code or .htaccess or something else would be enough for now.


edit: i wll try your embedded html suggestion.

 

Mayfriday0529

Diamond Member
Sep 15, 2003
7,187
0
71
Originally posted by: kamper
There's a bunch of ways. The most transparent is the Location: http header. To do that you either need to be able to tell your web server to do the redirection or you need to write a page in a server side language like php or jsp.

You can also embed it into your html with a tag like the following:

<meta http-equiv="refresh" content="?;URL=http://www.test.com/gallery"/>

where ? is the number of seconds to wait before redirection. I suppose you could substitute "Location" for "refresh" since http-equiv is meant to be interpreted as an http header. I'm just going on examples I've seen though, so I don't know how well a browser would handle that. That meta tag goes in the <head></head> section, btw.

So, if you have further questions, please specify a bit about your hosting environment (server, any languages available....)

This Worked Thank you.
 

wallsfd949

Golden Member
Apr 14, 2003
1,002
0
0
While the above may have worked, many users can become frustrated with your site if you use a meta http-equiv='refresh' as it affects the functionality of the 'back' button on the browser. It also may be noteworthy that search engines do not like 'refresh' (this may or may not affect you). If you can put a .htaccess file in the root directory of your site or whatever directory you want redirected would be the best choice for SEO and users.

.htaccess file:

redirect permanent / /gallery/



This can also be used to redirect test.com to testme.com:

redirect permanent / http://testme.com/

The SE will also note a permanent redirection and should not terribly affect the page ranking.
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
I tested the refresh solution before telling him about it and didn't have any trouble in IE or firefox. Failing that, the javascript location.replace() should work properly.