Forum Moderators: coopster

Message Too Old, No Replies

Very basic PHP tutorial available?

Total moron needs very basic tutorial to get started

         

Pro_Editor

11:27 pm on Mar 13, 2006 (gmt 0)

10+ Year Member



Long story short:
I am not a programmer, and I want to do a 301 redirect for my site and do not have access to htaccess.

But I do have access to PHP apparently with certain site packages (and found the code to use online). I signed up and got lots of great new files and have no clue what to do with them.

So, is there a really basic step-by-step tutorial for what to do with PHP? I just want to forward my html pages, and need a really basic instruction source that probably starts something like: make a new file and name it X.

You get the idea. I am clueless.

grandpa

4:04 am on Mar 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You don't need PHP for your redirects. The meta refresh tag is your option if you cannot access the .htaccess file. Along that line, you really should consider using hosting that will allow you to have some control over your site. Of course, then you'll need to learn Apache too, but we all did ;) Trust me on this, you will be happier if you can access your server files, or at least some of them. Here's the meta refresh command that you need in the HEAD section of each page that you want to redirect.

<meta http-equiv="Refresh" content="n;url">

n is the number of seconds to wait before loading the specified URL.
url is an absolute URL to be loaded.

<META HTTP-EQUIV="refresh" content="1;URL=http://www.domain.com/index.htm">

As far as PHP references, you might want to see if there is a PHP for Dummies out there... not to imply anything, but it could be helpful at first.

maerk

2:45 pm on Mar 15, 2006 (gmt 0)

10+ Year Member



I've sent you a sticky mail with two good ones I use.

I think what you're looking for is

header("Location: http://www.example.com/");
header("HTTP/1.1 301 Moved Permanently");

Using meta refresh is frowned upon by search engines and the like. Plus they're annoying for users (it breaks the back button). You're right to stick to server-side redirects, that way you can send useful HTTP information along with the new URL.

If it really must be client side, you could always insert the link you want to redirect into the body of the page. That way when a visitor clicks "back" they won't be held in an endless loop while your page redirects them to another place... I hate it when that happens!