Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1592 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

PHP Redirect

Thread title: PHP Redirect
Closed Thread  
Page 2 of 2 < 1 2
    Thread tools Search this thread Display Modes  
02-17-2007, 11:34 PM
#11
Zara is offline Zara
Status: Member
Join date: Apr 2006
Location:
Expertise:
Software:
 
Posts: 249
iTrader: 9 / 100%
 

Zara is on a distinguished road

  Old

Originally Posted by Kirth View Post
You can also use javascript:

PHP Code:
<html>
<
head>
<
script language="JavaScript">
<!--
// author: Kirth
// description: redirects to where you want!
// necessary mods: change the '/forum' to where you want it to go to (I did it for you
window.location="/wordpress";

//-->
</script>
<head> 
<title>Redirecting please wait...</title>
</head>
<body>
Hi there! Please wait while we redirect you!
</body>
</html> 
Not the best of idea as some people may have JS disabled...

02-26-2007, 01:20 AM
#12
deLive is offline deLive
Status: I'm new around here
Join date: Feb 2007
Location:
Expertise:
Software:
 
Posts: 8
iTrader: 0 / 0%
 

deLive is on a distinguished road

  Old

Another option is with javascript. window.location=""

02-26-2007, 02:11 AM
#13
jono1 is offline jono1
jono1's Avatar
Status: Non-conformist
Join date: Jul 2005
Location: Canberra, Australia.
Expertise:
Software:
 
Posts: 1,172
iTrader: 0 / 0%
 

jono1 is on a distinguished road

  Old

PHP is the best option - Javascript and Meta redirects will load the page first and then visibly redirect to the new page - that is, if the user looked through their browsing history afterwards, they'd see the redirect page and the page they wanted. A PHP redirect works through the headers so it's completely invisible to the end user - so in the history only the page the user wanted would show up.

02-26-2007, 08:12 PM
#14
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

PHP is not the best option, that requires your server to fire up the PHP engine each time the redirect occurs. Using htaccess (or httpd.conf) would be the better choice by far.

02-26-2007, 09:19 PM
#15
RaZoR^ is offline RaZoR^
RaZoR^'s Avatar
Status: Member
Join date: Feb 2006
Location:
Expertise:
Software:
 
Posts: 191
iTrader: 1 / 100%
 

RaZoR^ is on a distinguished road

  Old

Redirecting from the web server is the best option, not redirecting from a module installed on the web server. This takes up less resources and if I'm not corrected, a very small amount of bandwidth will be kept from this

JavaScript is a bad option. A lot of the users here will probably have JS enabled because they are designers and such and won't be up for using text-based browsers. In the interest of accessibility, Internet Explorer uses who turn off scripting and other users who don't like client-side scripting enabled, you should avoid using JavaScript where you can.

The same goes for Meta Refreshing. The page has to first be loaded, and if you come across a user with a strict browser, it may not render the page properly without making it HTML/XHTML compliant. This would be even more of a waste of bandwidth, server resources and because users would have to wait for the page to load, resources, bandwidth and time of your users.

Assuming you're buying from a clever server host using Apache, then the following would just be slapped into the .htaccess file in your root folder:

Code:
DirectoryIndex /wordpress/index.php
This actually sets the directory's index page to the directory you've stored your wordpress blog in It's not a redirect as such, but I didn't think being correct with HTTP headers would be very significant. If you want to be correct on this, in the same file you would have put the above in, put:

Code:
Redirect permanent /index.html /wordpress/
Just create a file called index.html, leave it blank, put it in the root directory, the above in .htaccess in the root directory and you're laughing.

(Sorry for jabbering on)

02-26-2007, 09:46 PM
#16
localhost is offline localhost
localhost's Avatar
Status: Dediport Hosting
Join date: Jul 2006
Location: Berkshire
Expertise: programming, business
Software: Dreamweaver
 
Posts: 1,316
iTrader: 17 / 100%
 

localhost is on a distinguished road

  Old

I would agree.. .htaccess is the best way.

You know the other ways.. Maybe a PHP and a Javascript.. Then you will suit both audiences.

02-27-2007, 01:50 AM
#17
jono1 is offline jono1
jono1's Avatar
Status: Non-conformist
Join date: Jul 2005
Location: Canberra, Australia.
Expertise:
Software:
 
Posts: 1,172
iTrader: 0 / 0%
 

jono1 is on a distinguished road

  Old

I only say PHP is the best option because mod_rewrite isn't always installed (or enabled) on servers and if you're on shared hosting it's generally difficult to get it enabled. PHP is available almost universally.

Closed Thread  
Page 2 of 2 < 1 2


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed