Unstoppable Domains

PHP and SEO

Spaceship Spaceship
Watch

SwiftyCorleone

Established Member
Impact
13
Hello, I am currently working on a website which uses PHP include function to obtain pages. I am no way a great coder in PHP. The code im using is available online.

Basicly ive placed the following code in a table and when a link is clicked it opens up in the table. Im just wondering how search engines react to this kind of system and if theres a better way of doing it.

PHP:
<?php

function home()
{
include "inc/home.php";
}
$choice=$_GET['pg'];

switch($choice)
{
case "home": include "inc/home.php"; break;
case "biography": include "inc/biography.php"; break;
case "discography": include "inc/discography.php"; break;
case "media": include "inc/media.php"; break;
case "shop": include "inc/shop.php"; break;
case "forum": include "inc/forum.php"; break;
case "contact": include "inc/contact.php"; break;
default: 
home();
}
?>

I then place this <a href="?pg=home">Home</a>

Once the page is loaded i get urls like:

http://www.thewebsitename.com/?pg=home
http://www.thewebsitename.com/?pg=audio

I would like my urls to be like the following:

http://www.thewebsitename.com/home
http://www.thewebsitename.com/audio

Thanks for taking the time to read this and for the help in advance.

Darren.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
.US domains.US domains
Search engines will still spider your urls, but you're right, the "/audio/" format is superior.

except: imho, you don't want /home because then you will have the same content on the root "/" page and on the "/home" page.

if your host uses apache, you can use a .htaccess file so that you don't have to change you code ( just the links everywhere ).

i think a .htaccess file like this should do the job:

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?pg=$1 [QSA,L]
</IfModule>
 
0
•••
The home.php is needed because the PHP code i have used works similar to a frame. Ive heard of using .htaccess files and mod-write but not to sure.

How would i work this file into my site?

Thanks for taking the time to respond and sorry for the noobish questions.

Darren.
 
0
•••
Just to clarify, I'm not saying that having home.php is bad, I'm saying that having the same content available on site.com/ and site.com/home/ is bad ( duplicate content ).

To use the .htaccess file, create a file called .htaccess in your webroot ( e.g. site.com/.htaccess ) and put the code I posted earlier in it.

BTW, your code is a fusebox methodology ( everything goes through a central file which uses switches to determine the correct content to display )
 
0
•••
Yes i placed the file in the web root with the code you stated but nothing seems to have changed. Do i have to edit anything else?

The url http://www.bigpunisher.co.uk

The site is very basic as i am not a web master as you can tell.

Thanks, Darren.
 
0
•••
0
•••
0
•••
really, you'll need to change your links. so that they are all like you requested: /audio /media /someotherpage
 
1
•••
Excellent -NC- thank you ever so much for your help. Really appreciated.

Just one more thing, you said about not having Home.php linked to "Home".

Would this be correct in changing the link to,

<a href="index">Home</a>

Other than everything else is great, if you have any more tips or ideas please fill free to comment.

Thanks, Darren.

Rep Added.
 
0
•••
for linking to your homepage, i would recommend:

<a href="/">Home</a>

happy to help ;)
 
0
•••
Excellent, duh should of thought of that.

Thanks once again.

Darren.
 
0
•••
That's Very Simple. You should include the following code to decode URLs:

PHP:
$urldata = explode("/",$HTTP_SERVER_VARS['PATH_INFO']);

For example, if your URL is

site.com/home

then it will be decoded into "home" in the first element i.e

PHP:
$urldata[0] = "home";

^ This code is a sample.

You can define a switch case loop using this method.

In this, the URL appearing after the script name (here the default index page) is decoded.

If you want paths like /home/abcd/def ; They can also be done using the same code except that the $urldata variable will contain more elements 1,2. The array elements have to accessed by index nos. only. (Use while or for loop).

Please give me a rep if this solves your problem !
 
0
•••
Dynadot โ€” .com Registration $8.99Dynadot โ€” .com Registration $8.99
Appraise.net
Unstoppable Domains
Domain Recover
DomainEasy โ€” Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back