Solved

Site archetecture question

Posted on 2011-02-19
6
808 Views
Last Modified: 2012-05-11
Hi,

I am curious as to how to dynamically create pages. I see websites like facebook and youtube have pages for each of their users..... like:

facebook/me

OR

youtube.com/user/me

Would they be creating actual pages for each user or would they have one page that calls the users profile from the db?

If they are using the one page method how is google able to index this type of thing if it doesn't physically exist.

thanks!
0
Comment
Question by:Solutionabc
6 Comments
 
LVL 2

Expert Comment

by:TimBare
ID: 34935322
they usually use mod rewrite to rewrite the URL... So you're right. they don't have different pages.

If you're familiar w/ Joomla!, it does something similar when it changes a link using mod rewrite from
http://tbare.com/index.php?option=com_content&view=article&id=4&Itemid=4

Open in new window

to
http://tbare.com/portfolio

Open in new window

0
 
LVL 6

Expert Comment

by:MatthewP
ID: 34935590
One page that calls the users profile from the db is the correct answer.

In apache web server on linux this is done using a special file called .htaccess that sits in a directory and consists of rules for sending the browser to a different page that is displayed. A very simple example of a .htaccess file would be:
Options +FollowSymlinks
RewriteEngine On
RewriteRule page_that_does_not_exist.html page_that_does_exist.html

Open in new window

- in this example the page that the web browser displays is not the one that the user has typed into the address bar of the web browser. Create the page_that_does_not_exist.html and you can call it from the other url in the file - which remains displayed in the address bar.

.htaccess files use regular expressions too:
RewriteRule /user/(\w+)/ homepage.php?user=$1

Open in new window

In the example above the parentheses grab are used to capture a match and store it in $1 - fairly standard regular expression behaviour - which can then be passed as a GET variable to the script that is called. If you make multiple matches they go into $1,$2,$3 etc and you pick them up in your script as usual - in the example above you'd use $_GET['user']

http://corz.org/serv/tricks/htaccess2.php - the first link from searching "htaccess mod rewrite" in google - looks like it covers it all in more detail.
0
 

Author Comment

by:Solutionabc
ID: 34937509
so with mod rewrite does google still index every user's page?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 6

Accepted Solution

by:
MatthewP earned 500 total points
ID: 34937558
Yeah it does because as far as the outside world can see they're all real pages with different content. I use Mod rewrite for providing search engine friendly urls where index.php?id=5&content=9&template=34 for example is pretty meaningless to both search endines and users.

I have things on my sites like:
RewriteRule products/(\d+)/?.*?$ index.php?s=9&content=95&template=15&product_id=$1

Open in new window

This allows a url such as mysite.com/products/5129/Title-of-my-product.html to call up a product entry from a database. Matching with .* after the id allows the title to be completely irrelevant to what is served, therefore it can be tailored for SEO - only the product id which is captured by \d+ (one or more numbers) is actually passed to the script, the product title is of course read by search engines and users alike. All the script does at the other end is get the value of $_GET['product_id'].

Note this is all an apache web server thing, though similar methods are available for Windows if you host on there: http://www.micronovae.com/ModRewrite/ModRewrite.html for example.
0
 

Author Comment

by:Solutionabc
ID: 34937775
great information thanks.
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 34937778
Any URL can be indexed by Google.  The URL itself is not very important, except as a human-centric mnemonic.  It's easier to remember something like http://twitter.com/LandonBaseball but the computers do not really care about the URL.  Google cares about the content of the pages, most particularly about the title and h1 tags as well as the meta description.  Google also cares about how many other pages link to any given page, and what the other page links contain in the text of the anchor tag.

This is a good book that teaches the basic design of data base backed web sites.  General purpose scripts create the HTML for pages.  The exact content of any page is determined from the contents of an underlying data model.
http://www.sitepoint.com/books/phpmysql4/
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Insert won't work due to space in column name 5 22
Php recording post 4 51
Showing random records from database 10 37
FrontEnd tools to create web database application 7 62
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question