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

Joey
  • 344,408
  • 85
  • 689
  • 683
JasonDavis
  • 48,204
  • 100
  • 318
  • 537
  • 2
    No answer, but from your users' perspective, *please* do this: Any URL with a query string is uncacheable according to the spec. So your current structure forces a re-GET every time. – T.J. Crowder Sep 20 '09 at 22:20
  • @T.J. Crowder: According to what specification? Please prove that assertion. – Gumbo Sep 20 '09 at 22:26
  • @Gumbo: The HTTP specification, Section 13.9 for example - http://www.faqs.org/rfcs/rfc2616.html – T.J. Crowder Sep 20 '09 at 22:34
  • 1
    This applies to HTTP 1.0 and to cases where no explicit caching information is provided. If query strings are supposed to act as no-cache indicators, then you might want to tell that to a few browser vendors out there. – Rob Sep 20 '09 at 22:37
  • @T.J. Crowder: You name it: “[…] caches MUST NOT treat responses to such URIs as fresh *unless* the server provides an explicit expiration time.” – Gumbo Sep 20 '09 at 22:39
  • @Gumbo: Precisely. Check your headers; are *you* supplying explicit expiration times? If you are, good on you and mazel tov. – T.J. Crowder Sep 20 '09 at 22:44

1 Answers1

8

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
  • 7,125
  • 4
  • 33
  • 42
  • Oops. The "nope" was an answer to his question "does it create more processing work?" Fixed - thanks. – BraedenP Sep 20 '09 at 22:29
  • 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 Sep 20 '09 at 22:51
  • 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 Sep 20 '09 at 23:10