views:

116

answers:

1

My site currently handles URL's like this...

/?p=home  
/?p=profile&userid=1  
/?p=users.online  
/?p=users.online&page=23  
/?p=mail.inbox  
/?p=mail.inbox&page=12

... and so on, there is probably at least 120-150 different pages, on my site a page is built like this,

index.php includes a main config file which then includes function/class files into it
index.php then includes a header file
index.php then includes the page file which is from the url ?p=pagename
index.php then includes a footer file

That is how every page on my site is compiled, through the index page like that and I have been considering/thinking about cleanning up the URL's as I am re-writing/restructuring most of my sites code right now, it's the perfect time to do it if I am going to do it. What I mean by cleanning up the URL's is using mod-rewrite so the URL structure above would look like this instead...

/home
/users/1  //user ID might switch to use username as well
/users/online
/users/online/23 or /users/online/page/23
/mail/inbox
/mail/inbox/12


So first of all is there any downfalls to doing this, does it create a lot more processing work since it is using mod_rewrite?

Also would it be hard to write the regex or whatever is needed to match the file names in the format that I show above, I listed only a few of the pages but there would be at least 100 different URL pages I have blogs, bulletins, forums, all kinds of stuff

+8  A: 

Absolutely. That's one of Apache's main purposes, so it's been designed to do it very efficiently. In fact, I'd emplore you to use that method.

  1. It makes cleaner URLs for visitors
  2. It's fantastic for SEO
  3. It makes the website more professional
  4. It makes it easier for users to guess URLs if they are trying to find a certain page without actually traversing through your site ti find it.

There are no downfalls, and a ton of advantages to using that URL structure. Go for it!

BraedenP
Oops. The "nope" was an answer to his question "does it create more processing work?" Fixed - thanks.
BraedenP
thanks for the answer, 1 thing I have been uncertain of is many of my sections I have paging like page=12 so I didn't know if this woyuld cause a problem when there is no paging for that page, for example if you are on page 1 then it does not show any paging data in the url
jasondavis
jason: Get help with your specific regex problems when you experience them. Go get implementing now... Besides, it's EASY to go from blah/whatever/p# to your query string...
Paul McMillan