Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP URLs that are user friendly
Old 02-13-2009, 02:46 PM PHP URLs that are user friendly
Junior Talker

Posts: 3
Name: Tom
Trades: 0
Hi,

I'm just finishing creating a site that is almost entirely database driven... from the content to the graphics, it's all stored in databases to easily swap things in and out. What I'm wondering though is how to make my urls more user friendly so that people don't have to either: 1) start at the index page every time or 2) have to remember a url that is littered with variables. Also, this site has over three thousand "pages", each a belonging to a seperate business... so having to hard-code friendly urls isn't an economical option. Any suggestions or perhaps documentation out there concerning this? I've done some searching and haven't turned up much that's helpful.

Thanks
tsanders is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-13-2009, 10:45 PM Re: PHP URLs that are user friendly
Novice Talker

Posts: 4
Name: Samuel Santos
Trades: 0
Hello Junior Talker.

Do you know Joomla?
Joomla is a great system, with all ressourses.
If you don't know, please visit www.joomla.org

Samuel de Sousa Santos
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
inglescurso is offline
Reply With Quote
View Public Profile Visit inglescurso's homepage!
 
Old 02-18-2009, 07:19 AM Re: PHP URLs that are user friendly
Novice Talker

Posts: 5
Trades: 0
I don't know exactly what you can do, but on my websites (which helds thousands of pages too), I use variables.
You CAN also use URLs like this: http://www.domain.com/business-categ...-name-here.php
I rather use variables like this www.domain.com/business.php?id=[businessID]
Not too hard to remember.
__________________

Please login or register to view this content. Registration is FREE
Ariyes1 is offline
Reply With Quote
View Public Profile
 
Old 02-20-2009, 09:21 AM Re: PHP URLs that are user friendly
Novice Talker

Posts: 9
Name: Bryan Smith
Trades: 0
Quote:
Originally Posted by tsanders View Post
Hi,

I'm just finishing creating a site that is almost entirely database driven... from the content to the graphics, it's all stored in databases to easily swap things in and out. What I'm wondering though is how to make my urls more user friendly so that people don't have to either: 1) start at the index page every time or 2) have to remember a url that is littered with variables. Also, this site has over three thousand "pages", each a belonging to a seperate business... so having to hard-code friendly urls isn't an economical option. Any suggestions or perhaps documentation out there concerning this? I've done some searching and haven't turned up much that's helpful.

Thanks
If the site is driven by database then I hope you can create urls dynamically as well.

Let us take an example: if you have products in several categories you can format the url structure as: http://www.yoursite.com/products/<category-name>/<product-name>/product-<id>

Now using your htaccess you parse the url and get the last item after "/" which is product-<id> so you run product.php like this product.php?productid=<id>

Hope that helps.
__________________

Please login or register to view this content. Registration is FREE
: Cost effective PHP Resources for Hire

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
bryansmith is offline
Reply With Quote
View Public Profile
 
Old 02-20-2009, 08:29 PM Re: PHP URLs that are user friendly
Average Talker

Posts: 15
Trades: 0
Instead of using the $_GET super global you could do domething like this.

Code:
http://www.yoursite.com/index.php/value1/value2/article_name-51.html
PHP Code:
$url $_SERVER['REQUEST_URI'];
$urlArray explode("/",$url); 
Returns
Code:
Array
(
    [0] => index.php
    [1] => value1
    [2] => value2
    [3] => article_name-51.html
)
PHP Code:
$pageArray explode("-",$urlArray[3]); 
Returns
Code:
Array
(
    [0] => article_name
    [1] => 51.html
)
PHP Code:
 $pageId stristr($pageArray[1], '.html'true);
//$pageId = 51
$pageName $pageArray[0];
//$pageName = article_name 
This is not tested, just off the top of my head, but should work.

Regards, George

Last edited by GOPalmer; 02-20-2009 at 08:33 PM..
GOPalmer is offline
Reply With Quote
View Public Profile
 
Old 02-20-2009, 10:06 PM Re: PHP URLs that are user friendly
itscooper's Avatar
Super Talker

Posts: 147
Location: Herts, UK
Trades: 0
Personally I'm accustomed to bryansmith's method for using .htaccess mod_rewrite. That's how I've always done it and it works for me. Turning them into flat links.

I found it a little complex when I first tried it... but after doing it once or twice I got the hang of it.

This looks like a good article (although I admit I only skimmed it):
http://corz.org/serv/tricks/htaccess2.php

Or google 'mod_rewrite flat links' or something.

Thanks, hope you find a solution that works for you
__________________
itsCooper

Last edited by itscooper; 02-20-2009 at 10:08 PM..
itscooper is offline
Reply With Quote
View Public Profile Visit itscooper's homepage!
 
Old 02-23-2009, 09:26 PM Re: PHP URLs that are user friendly
mobilegame's Avatar
Extreme Talker

Posts: 185
Trades: 0
I do not thinks Joomla is good as far as url is concerned, ugly url! and if you use rewrite, most of the time it returns a page not found error.
mobilegame is offline
Reply With Quote
View Public Profile Visit mobilegame's homepage!
 
Old 02-24-2009, 07:23 AM Re: PHP URLs that are user friendly
Banned

Posts: 9
Name: Liza Potter
Location: UK
Trades: 0
You can pick some CMS for your purpose as it will make many things easy for you like Joomla, wordpress or Drupal
Lizapotter is offline
Reply With Quote
View Public Profile Visit Lizapotter's homepage!
 
Old 02-24-2009, 10:15 AM Re: PHP URLs that are user friendly
anderswc's Avatar
Super Talker

Posts: 132
Name: Will Anderson
Location: Terre Haute, IN
Trades: 0
If you're set on using your own system, .htaccess and mod_rewrite are the way to go. Using a system like Joomla or WordPress that already has permalinks built in might be easier.
__________________
Will Anderson

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
anderswc is offline
Reply With Quote
View Public Profile Visit anderswc's homepage!
 
Old 02-24-2009, 09:51 PM Re: PHP URLs that are user friendly
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
For a full circle of function, you would simply need only mod_rewite to convert the user friendly urls to the php param based url for your page scripts. However, you would need to build a href link output function or class to dynamically build your internal links back to the user friendly url.

for sake of an example:

<a href="<?php echo user_funtion_href('page', $params_array, $request_type); ?>">Link</a>
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 02-26-2009, 07:44 PM Re: PHP URLs that are user friendly
randon's Avatar
Experienced Talker

Posts: 46
Name: Brandon
Trades: 0
yeah use .htaccess for the easiest and cleanest solution
__________________

Please login or register to view this content. Registration is FREE
Web development blog and scripts.
randon is offline
Reply With Quote
View Public Profile
 
Old 02-28-2009, 05:48 AM Re: PHP URLs that are user friendly
Jaryth000's Avatar
Skilled Talker

Posts: 59
Name: Jaryth
Location: Canada
Trades: 0
Using the above mentioned .htaccess and mod_rewrite, you can make links that look like:

www.site.com/index.php?file=about
(or other more complex things)
to
www.site.com/pages/about
and it would result in the same thing.
An example for the above for an .htaccess file would be something like:

Quote:
RewriteEngine on
RewriteRule ^pages/([^/\.]+)/?$ index.php?file=$1 [L]
so that whatever is after the /pages/ directory, gets automatically put after the index.php?file= line. To the end user, all they see is nice links. While the server sees the full requested URL.

Its best to read up on it and understand it before using it however, as it can be a tad tricky.
__________________

Please login or register to view this content. Registration is FREE
My personal website
-Jaryth (UID590)
Jaryth000 is offline
Reply With Quote
View Public Profile Visit Jaryth000's homepage!
 
Reply     « Reply to PHP URLs that are user friendly
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.35911 seconds with 12 queries