here’s how I do :
- the user types a URL
- the mod_rewrite handles URLs of the form :
^([^/\.]+)/?$(the first
segment in the path) - and redirect them to the index page :
struct.php?page=$1 -
in the index page (struct.php) I request the content of the page
($_GET[‘page’]) if it exists :$content = @file_get_contents("pages/$_GET[page]/.content") - if the content doesn’t exist, I just request the content of the page
'not_found/.content'
This is working but I’d like to keep things simple in the script and use the power of mod_rewrite to request only the pages that exist.
here’s how I’d like to do :
- the user types a URL
- the mod_rewrite handles URLs of the form :
^([^/\.]+)/?$(the first
segment in the path) - and redirect them to the index page only if the
.contentfile has been found :struct.php?page=$1
here’s my try:
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond pages/$1/.content -f RewriteRule ^([^/\.]+)/?$ struct.php?page=$1 [L] </IfModule>
note : I’m using an .htaccess file
Here’s my solution: