TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 11-14-2008, 06:32 PM   #1 (permalink)
how quixotic are you?
 
ETbyrne's Avatar
 
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
ETbyrne is on a distinguished road
Default Search Engine Friendly URLs in PHP Without Mod_Rewrite

I wrote a tutorial on how to make nice looking, search engine friendly URLs in PHP without using Mod_Rewrite.

Basically you can make a URL that normally looks like this:

Code:
http://www.yourdomain.com/index.php?page=about&user=Evan&index=2
Look like this:

Code:
http://www.yourdomain.com/index.php/about/Evan/2
Here is the link to the article:
> http://www.evanbot.com/article/fancy...-mod_rewrite/3
__________________
Dingo Web Systems > http://www.dingocode.com
My Website > http://www.evanbot.com
ETbyrne is offline  
Reply With Quote
The Following User Says Thank You to ETbyrne For This Useful Post:
codefreek (11-16-2008)
Old 11-14-2008, 11:05 PM   #2 (permalink)
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 336
Thanks: 8
tony is on a distinguished road
Default

thanks, definitely would look into it.
tony is offline  
Reply With Quote
The Following User Says Thank You to tony For This Useful Post:
ETbyrne (11-15-2008)
Old 11-15-2008, 01:13 AM   #3 (permalink)
The Addict
 
Enfernikus's Avatar
 
Join Date: Jun 2008
Posts: 335
Thanks: 2
Enfernikus is on a distinguished road
Default

You don't necessarily need to get rid of the file from the string for instance

PHP Code:
<?php

function getURL$num )
{
    
$arURL explode('/'$_SERVER['REQUEST_URI']);
    return ( isset( 
$arURL[$num 1] )) ? $arURL[$num 1] : false;
}

?>

Going on, this might be an appealing way of circumventing some of the problems associated with mod_rewrite but let's say your system depends on modules ( as do many ) so that you're unfriendly url looks like so

index.php?mod=user&act=login

Your friendly-esk URL would look like so

index.php/mod/user/act/login

or

index.php/user/login


Using mod_rewrite you can achieve domain.com/login which looks still more appealing then any of the url's your method. I'm not trying to defame your attempt to come up with alternatives to mod_rewrite merely state that mod_rewrite is much more flexible and gives much more control for urls.
Enfernikus is offline  
Reply With Quote
The Following User Says Thank You to Enfernikus For This Useful Post:
ETbyrne (11-15-2008)
Old 11-15-2008, 04:47 PM   #4 (permalink)
how quixotic are you?
 
ETbyrne's Avatar
 
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
ETbyrne is on a distinguished road
Default

@Enfernikus: Yes. You are definitely right, Mod_Rewrite is much more powerful than this method. But, the two methods could easily be used together to be more powerful that ether one alone! Again, a good example of this would be how CodeIgniter handles URLs.

You could use the following Mod_Rewrite code in a .htaccess file to remove the index.php:

Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|img|robots\.txt|anotherdir)
RewriteRule ^(.*)$ index.php/$1 [L]
__________________
Dingo Web Systems > http://www.dingocode.com
My Website > http://www.evanbot.com
ETbyrne is offline  
Reply With Quote
The Following User Says Thank You to ETbyrne For This Useful Post:
codefreek (11-16-2008)
Old 12-08-2008, 08:39 PM   #5 (permalink)
The Visitor
 
Join Date: Dec 2008
Posts: 1
Thanks: 0
parsaman is on a distinguished road
Default help me about mod_rewrite

hi
i have a problem to use this module for change my link to seo.
i have a simple link:www.domain.com/product_desc.php?id=number
to :www.domain.com/product/number
I use this rules:
RewriteRule ^product/([A-Za-z0-9-]+)/?$ product_desc.php?id=$1 [NC,L]
I change ([0-9]+) or (.*) or ([^.]+)and etc..
and i test similar flag too.[QSA]..
but not successfull because my order page show without picture and css and was added product/ in first other links in page
please help me to skip
thanks
i use - instead / in this method it worked.why?
parsaman is offline  
Reply With Quote
Old 12-09-2008, 08:33 PM   #6 (permalink)
The Contributor
 
Izym's Avatar
 
Join Date: Sep 2007
Posts: 32
Thanks: 0
Izym is on a distinguished road
Default

I usually make a class that works either way and auto checks if the url is with or without mod_rewrite. Could post a tutorial on making such class if people want.
Izym is offline  
Reply With Quote
Old 12-09-2008, 10:50 PM   #7 (permalink)
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 336
Thanks: 8
tony is on a distinguished road
Default

Izym, I would be really interested in that tutorial, since I am also barely starting in this url rewrite realm.
tony is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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


All times are GMT. The time now is 03:52 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design