Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

stu02

macrumors newbie
Original poster
Aug 1, 2006
10
0
Edinburgh, Scotland
So I’ve developed my own content management system powered by PHP and MySQL and each page is produced by pulling the content from the database on each visit. So far it works perfectly and to make things look a lot more refined I thought I’d tidy up the URLs using Apache’s mod_rewrite.

Anyway the problem is I just can’t get it to work, I know for a fact that Apache is configured properly because I managed to rewrite the URLs of static PHP pages.

The URL to access a page can be done in two ways, either providing the page ID or the page name, for example:

http://www.example.com/index.php?page=page-name-here

OR

http://www.example.com/index.php?page=2

After reading about a million tutorials and google search results I came up with the following .htaccess file which I’m pretty sure should work.

Code:
Options +FollowSymLinks 
RewriteEngine On
RewriteRule ([A-Za-z0-9]+)$ /$1/ [R]
RewriteRule ([A-Za-z0-9]+)/?$ index.php?page=$1 [L]

But it doesn’t, so my question is what am I doing wrong?

Thanks
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.