1

Can anyone explain how to create friendly URLs? I mean URLs like http://store.steampowered.com/app/22600/ that doesn't have any pages like index.php visible.

tshepang
  • 12,111
  • 21
  • 91
  • 136
Joey Morani
  • 25,431
  • 32
  • 84
  • 131
  • possible duplicate of [Accessing URLS by www.example.com/page instead of www.example.com/page.php](http://stackoverflow.com/questions/1669260/accessing-urls-by-www-example-com-page-instead-of-www-example-com-page-php) – Wrikken Aug 04 '10 at 21:52

4 Answers4

4

If you only have cpanel use .htaccess.

If that doesn't work, you are left with parsing the url in php with a link like this:

http://server.com/router.php/search

You can do that with something like this.

<?
list($junk,$url) = explode("router.php",$_SERVER['REQUEST_URI']);
$paths = explode("/", $url);
if ($paths[0] == 'search')
{
   Header("Location: /search.php");
}
?>
tshepang
  • 12,111
  • 21
  • 91
  • 136
Byron Whitlock
  • 52,691
  • 28
  • 123
  • 168
1

http://articles.sitepoint.com/article/search-engine-friendly-urls

http://www.alistapart.com/articles/succeed/

Search revealed dozens more

riwalk
  • 14,033
  • 6
  • 51
  • 68
1

You need to look up apache mod_rewrite (assuming you are using apache for your web server). PHP itself doesn't do it for you the web server does most of the work. You need to tell your web server to use mod_rewrite to point all urls that match a certain pattern to point to what ever .php file you like. You can pass arguments in your url pattern what ever way you choose. e.g. using the / to delimit key values or just values. If you don't have root access to the server and its enabled you can usually put these mod rewrite rules in a .htaccess file at the root of your site.

Sitepoint have a good reference for beginners. http://articles.sitepoint.com/article/guide-url-rewriting

Derek Organ
  • 8,323
  • 17
  • 56
  • 75
0

if you're using apache this should work/is the idea:

RewriteRule ^(.*)$ /index.php?/$1 [L]

now your url will go to http://store.steampowered.com/index.php/app/22600/

Ken Struys
  • 1,789
  • 1
  • 10
  • 17