Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect everything to index.php

Tags:

redirect

php

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.

like image 364
pixel Avatar asked Apr 19 '10 16:04

pixel


People also ask

What is RewriteRule in htaccess?

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/.


1 Answers

.htaccess:

RewriteEngine on
RewriteBase /
RewriteCond  %{REQUEST_FILENAME} !-f
RewriteCond  %{REQUEST_FILENAME} !-d
RewriteRule  ^(.*)$ index.php?param=$1 [QSA,L]
like image 183
Your Common Sense Avatar answered Oct 26 '22 17:10

Your Common Sense