Page 1 of 1

Search Engine Friendly Urls generation with PHP?

Posted: Fri Jan 11, 2008 8:09 am
by Sindarin
Can anyone tell me if it is possible to use PHP code to make/generate search engine friendly urls?
The site I am working on is on Windows server and I use switches to navigate through the site, like:

<?php
switch($_GET['page']){
case 'about':
$include= 'about.php';
break;
case 'contact':
$include = 'contact.php';
break;
case 'info':
$include = 'info.php';
break;
default:
$include = 'index.php';
}
include($include);
?>

So when I go to about page, the url is: http://site.com/index.php?page=about which isn't search engine friendly from what I read.

btw: where has the cool php code highlighter gone?

Re: Search Engine Friendly Urls generation with PHP?

Posted: Fri Jan 11, 2008 9:24 am
by s.dot
You can manage this with PHP alone or with apache mod rewrites.

With PHP you can explode on the / in the URI path, with mod rewrite rules you can map query strings to more static looking uri's.

Re: Search Engine Friendly Urls generation with PHP?

Posted: Fri Jan 11, 2008 9:43 am
by JayBird
Sindarin wrote:btw: where has the cool php code highlighter gone?
It's coming back soon!

Re: Search Engine Friendly Urls generation with PHP?

Posted: Fri Jan 11, 2008 11:00 am
by Jonah Bron
Whew! I was getting worried there for a minute. :mrgreen:

Re: Search Engine Friendly Urls generation with PHP?

Posted: Fri Jan 11, 2008 3:16 pm
by Kieran Huggins
what you might want is a "router" in a front controller.

Take a look at the MVC pattern

Re: Search Engine Friendly Urls generation with PHP?

Posted: Fri Jan 11, 2008 7:55 pm
by Jonah Bron
Also, I think it should be this:

Code: Select all

<?php 
switch($_GET['page']){
case 'about':
$include= 'about.php';
break;
case 'contact':
$include = 'contact.php';
break;
case 'info':
$include = 'info.php';
break;
default:
//Change this to some other page
$include = 'main.php';
}
include($include);
?>
The other way, the file includes itself.

Re: Search Engine Friendly Urls generation with PHP?

Posted: Mon Jan 14, 2008 4:02 am
by Sindarin
:P I am not a scintilla lexer :lol: