Question

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

Was it helpful?

Solution

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!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top