# Blocking access to confidential files
<FilesMatch "\.(htaccess|htpasswd|ini|log|sh|inc|bak)$">
Order Allow,Deny
Deny from all
</FilesMatch>
# Rewrites for pretty URLs
<IfModule mod_rewrite.c>
RewriteEngine On
# Optional - The location of the project directory
#RewriteBase /path/to/project
# Ignoring any existing files
RewriteCond %{REQUEST_FILENAME} !-f
# Ignoring any existing directories
RewriteCond %{REQUEST_FILENAME} !-d
# Example 1 - Only pagination: http://localhost/path/to/project/index.php?n=1 OR http://localhost/path/to/project/index/n/1
RewriteRule ^([A-Za-z]+)/([A-Za-z]+)/([0-9]+)/?$ $1.php?$2=$3 [L]
# Example 2 - Pagination + Id + Slug: http://localhost/path/to/project/index/paginator/number-current-page/id/some-title
RewriteRule ^([A-Za-z]+)/([A-Za-z]+)/([0-9]+)/([0-9]+)/([\w\-\.]+)/?$ $1.php?$2=$3&id=$4&slug=$5 [L]
# For demo page: http://localhost/path/to/project/index/paginator/number-current-page/page-demo/page-name-demo
RewriteRule ^(\w+)/(\w+)/(\d+)/(\w+)/([\w]+)/?$ $1.php?$2=$3&$4=$5 [L]
RewriteRule ^(\w+)/(\w+)/(\d+)/(\w+)/?$ $1.php [L]
RewriteRule ^(\w+)/?$ $1.php [L]
</IfModule>
|