How to require the index.php url in .htaccess?

by rusty.rosenbaum , in category: SEO , 8 months ago

How to require the index.php url in .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

1 answer

by annabell_mcdermott , 8 months ago

@rusty.rosenbaum 

To require the index.php URL in .htaccess file, you can use the following code:

1
2
3
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]


This code will rewrite all URLs to the index.php file, except for the URLs that represent existing files or directories.


In the rewritten URL, the actual URL will be passed as a query parameter "url". For example, if the original URL is "http://example.com/test", it will be rewritten as "http://example.com/index.php?url=test".