I'm trying to do clean URLs by exploding $_SERVER['REQUEST_URI']
and then switching between the results.
However, once a user goes outside index.php
, I'm assuming I need to redirect them back to index.php
in order to process the URL they want to reach. How can I accomplish this?
So for instance, if the user goes to www.domain.com/home/johndoe/...
I'd like index.php
(domain.com/index.php
) to be hit so that it can process the /home/johndoe/
via request_uri
.
htaccess rewrite rules can be used to direct requests for one subdirectory to a different location, such as an alternative subdirectory or even the domain root. In this example, requests to http://mydomain.com/folder1/ will be automatically redirected to http://mydomain.com/folder2/.
.htaccess:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?param=$1 [QSA,L]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With