KingPin's Forum
 
K.P.s.N. Register vbBux / KPs Mall Bugs Blogs FAQ Search Today's Posts Mark Forums Read Donate
Go Back   KingPin's Forum > KP's Network Forum > Tutorials & Stuff!
Reload this Page PHP : alternative to mod_rewrite for SE friendly URLs
 


Tutorials & Stuff! This is a discussion on PHP : alternative to mod_rewrite for SE friendly URLs in the Tutorials & Stuff!;
Description: Say for instance you are making a web hosting site want the url http://www.mod_rewrite.dom/something...tegory=hosting to pass variables back to a ...

Reply
 
LinkBack Thread Tools
PHP : alternative to mod_rewrite for SE friendly URLs
(#1 (permalink))
Old
KingPin's Avatar
KingPin is Offline
Da Boss!
KingPin has disabled reputation
 

My Mood:
 
Posts: 7,034
Thanks: 20
Thanked 17 Times in 15 Posts
Blog Entries: 22
Join Date: Apr 2004
Location: Brooklyn, NY
PHP : alternative to mod_rewrite for SE friendly URLs - October 11th, 2004

Say for instance you are making a web hosting site want the url
http://www.mod_rewrite.dom/something...tegory=hosting to pass variables back to a php script.

The most obvious thing to do is this.
Code:
$pagenumber= $post["page"]

$category=$post["category"]
Whereby you use $post to find out the value of the page, which in this case is 12 and the category which in this case happens to be hosting. There are two things wrong with using urls like this a.they are not user friendly and b.they are not search engine friendly.

You probably want a nice easy to use url that looks more like this.
http://www.mod_rewrite.dom/something...tegory/hosting

The big problem here is getting the variable values back to the php script displaying the page. The solution is to use a php script that looks more like this

$data = explode("/",serverVar('PATH_INFO'));
$page = $data[1];
$category = $data[3];

Explanation

the serverVar path_info returns the path of the url from where something.php is being accessed so in this case it will return page/12/category/hosting. This then gets exploded or broken down into the array $data

Code:
  * $data[0] = page

  * $data[1] = 12

  * $data[2] = category

  * $data[3] = hosting
This way you have access to all the data you need for your php script.
One Small Problem

If you look closely you will spot something strange with the resultant url
http://www.mod_rewrite.dom/something...tegory/hosting

The .php extension right in the middle of the url is a problem, some search engines may recognize this as improper format and wont index your site. And if you leave it out the server wont recognize that it is a php file, that is ofcourse unless you tell the server to treat the file as a .php file even if its missing the extension. So you want the url to look like this
http://www.mod_rewrite.dom/something...tegory/hosting

To do this you need to create a .htaccess file (blank text file named .htaccess). And insert the following code

Code:
<FilesMatch "^something$"> 

 < ForceType application/x-httpd-php >

</FilesMatch>
First the files match checks for the word 'something' in the url, then the force type directive tells Apache to recognize 'something' as a php file even though there is no extension in the url.
Comparison with mod_rewrite

Flexibility

Mod_rewrite is much more flexible than the php method, but whats fexible to some is complicated to others

SEO

I think that both are pretty much equal. The only problem with the php method is the urls sometimes become very long. Still this is more of a user friendliesness problem than a SEO problem

 
Reply With Quote
Revenue Shared Ads
PHP : alternative to mod_rewrite for SE friendly URLs
Revenue Shared Ads
Reply

Bookmarks

Tags
alternative, friendly, modrewrite, mod_rewrite, php, urls

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Rupees Per Thread View: 1.00
Rupees Per Thread: 15.00
Rupees Per Post: 5.00
Forum Jump



These are the 100 most searched terms
Search Cloud
_backup.rc antrix wow antrix wow server autocad 2007 keygen best google gadgets best wow character bt map devil may cry 4 crack enchanting leveling erika bella fuckteam fuckteam 5 georgina lempin gigistar gigistar topless kpsden kpsforum leatherworking guide leveling enchanting mangos custom vendors mangos item id mangos linux mangos server mangos spell id mangos wotlk mature creampie milena velba no rest for the ass object id wow phoenix marie this is sparta vipersdenforums voyage century bot windows activation workaround windows xp lite wotlk alpha private server wotlk private server wotlk server wotlk wiki wow leatherworking guide wow mount locations wow object id wow object id list wow object id's wow object ids wow objects id www.adobeflashplayer www.adobeflashplayer.com www.kpsforum.com xbox 360 mmorpg ... powered by Simple Search Cloud
Powered by vBulletin® Version 3.8.0 Beta 3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
Copyright 2004-2009 KPsN


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82