There are two solution that I know:
1. Redirect all request to main index.php
and route pattern on that file.
Create an .htaccess
file and put this code to redirect all URLs to index.php
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule .* index.php [F]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw|xml|jpg|ajx))$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
In this case, all request will redirect to index.php
and you can get the URL from $_SERVER['REDIRECT_URL']
and route requests.
If users request /a/b.html
, you can $_SERVER['REDIRECT_URL']
and use from different parts, you should use secure code in the 2 solution.
2. Handle routes with .htaccess
file directly
But I recommend solution #1
Options +FollowSymLinks
RewriteEngine on
RewriteRule a/b\.html index.php?controller=$1&action=$2