954,242 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

.htaccess url rewrites

I am trying to build a store site. I want it to have friendly urls such as "/home","/store","/store/5443405", etc. I just cant figure out how to give my url more than one level. i.e. "/home" << one level "/store/5443405" << 2 levels. My php file looks like this right now

<?php
include 'includes/functions.php';

$p = isset($_GET['p']) ? $_GET['p'] : 'home';

$page = $p.'.php';

if (file_exists($page)) {
include $page;
}
else {
print $page;
}

?>


and my .htaccess:

Options +FollowSymLinks
  RewriteEngine On

  RewriteCond %{SCRIPT_FILENAME} !-d
  RewriteCond %{SCRIPT_FILENAME} !-f

  RewriteRule ^(.*)$ ./index.php?p=$1
sun-tzu
Light Poster
40 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

Never mind. I figured it out by doing this:

Options +FollowSymLinks
RewriteEngine On

RewriteRule page/(.*) index.php?p=$1 [nc]
RewriteRule products/([0-9]+) index.php?p=products&product=$1 [nc]
sun-tzu
Light Poster
40 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: