Redirect everything to index.php

I am trying to clear the URL by blowing up $_SERVER['REQUEST_URI'] and then switching between the results.

However, as soon as the user goes beyond index.php , I assume that I need to redirect them back to index.php in order to process the URL that they want to reach. How can i do this?

So, for example, if the user goes to www.domain.com/home/johndoe/... , I would like to click index.php ( domain.com/index.php ) so that it can process /home/johndoe/ via request_uri .

+6
redirect php
source share
3 answers

.htaccess:

 RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?param=$1 [QSA,L] 
+19
source share

You can use Apache mod_rewrite to match regular expression URLs, including sending everything to index.php ,

+2
source share

You will need images and other files that will be displayed in index.php.

 RewriteEngine On 

Includes Rewite Engine

 RewriteCond %{REQUEST_FILENAME} !\.(jpg|jpeg|gif|png|css|js|pl|txt)$ 

If the file name is not equal to jpg, jpeg ... which is necessary for index.php

 RewriteRule ^(.*)$ index.php?q=$1 [QSA] 

Redirect to index.php.

Using:

With PHP, $_GET q will provide you with /articles/1987/12/20/RΓ©pa birthday/

If you split the variable in each slash with

 list($type, $date_year, $date_month, $date_day, $title) = split('[/-]', $_GET['q']); 

You will get exactly what you want.

+2
source share

All Articles