I'm sure this has been posted somewhere else but I can't find it. I have spent a few hours researching and trying everything I can thing of from sample code to generators. I have a site that is currently residing in a subfolder called "new". I will be moving the site to the root folder once it is ready for launch. The site is database driven and right now to access the pages you need to use a url like this:
http://domain.com/new/index.php?page=about
I would like to have it so the URL looks like this:
I have tried so many different things I don't know where to start. Here is the PHP code in index.php I use:
$page = (isset($_GET['page']) ? $_GET['page'] : 'home');
$data = get_data($page);
The get_data()
simply grabs the content from the database based on the variable that was passed to it in the URL. Yes, everything is properly escaped in the function before querying the database.
Here is my current .htaccess file:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /new/
RewriteCond %{REQUEST_FILENAME} -f [NC,OR]
RewriteCond %{REQUEST_FILENAME} -d [NC]
RewriteRule .* - [L]
RewriteRule ^([a-zA-Z0-9]+)$ index.php?page=$1
RewriteRule ^([a-zA-Z0-9]+)/$ index.php?page=$1
Oddly enough /new/home/ works but any other like /new/contact-us/ does not work. The only thing I can think of is /home/ is the only one without a '-' character in the url. Am I missing something in my .htaccess to account for this?