Reputation: 9
hoping someone can offer some assistance here. This is an issue with multiple layers. In short, I want to have pretty URLs that use a URL variable to a file within a folder.
So, I want http://www.example.com/?page=path/to/page to look like http://www.example.com/path/to/page/
On the index.php page, to load the above content:
require_once('content/'.$_GET['page'].'.php');
Current htaccess configuration:
RewriteEngine On
# Add trailing Slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*[^/])$ http://%{HTTP_HOST}/$1/ [L,R=301]
# Make URLs sexy!
RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [L]
I can get this to work with a top level page within the /content folder, however, when the php file I with to include is within a folder inside the /content folder, it does not work.
Any ideas?? I believe the issue comes down to using an addition / in the ?page= variable. htaccess doesnt seem to like that.
Upvotes: 0
Views: 126
Reputation: 9
After some playing, I figured it out. My regex was off.
Changed:
# Make URLs sexy!
RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [L]
to:
RewriteRule ^(.*)(/)/?$ index.php?page=$1 [L]
Upvotes: 1