Solved

Site archetecture question

Posted on 2011-02-19
6
806 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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 108

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

Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now