I am trying to map.htaccess to /books
or /books/
or /books/<url_slug>
:
Options All -Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ $1 [R=301,L]
# Map /books/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^books$ book.php [NC,L,QSA]
Result:
book.php:
<?php
echo '<h1>Books</h1>';
?>
Solved yesterday.
Options All -Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ index.php [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^books/?$ book.php [QSA,NC,L]
RewriteRule ^books/([^/]*)?$ book.php?title=$1 [QSA,NC,L]