0

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
1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by sun-tzu
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]
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.