htaccess to create centralized php files

advertisements

I have no idea how to achieve the following.

Currently I have a problem. Whenever a user goes to www.example.com or any link with same domain it will run a centralize.php (example). This PHP script will determine which PHP to call based on the links, something like centralized php files.

I tried to use .htaccess to achieve this without success. What am I doing wrong or is there are another way to do this?

RewriteEngine  on
RewriteRule /(.*) /iindex4.php$1 [PT]

The above is what I've tried so far but it does't meet my requirement and is obviously flawed or buggy.

Question summary - navigate any url with same domain it will run a certain PHP file - is there another way to do this beside .htaccess


Try this:

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

Then you can retrieve the requested URI from the script through the $_GET['q'] variable.