B
B
bar_boss2014-03-26 17:41:55
PHP
bar_boss, 2014-03-26 17:41:55

How to redirect all requests to index.php (.htaccess)?

It is necessary that all requests that come to the site are redirected to index.php

RewriteEngine On
Options +FollowSymlinks
RewriteBase /

DirectoryIndex index.php

RewriteRule ^(.*)$ index.php [L]

For example www.site.com/faq-one?id=5 - everything works fine
www.site.com/catalog?id=10 - 404 error
However, if you remove catalog.php at the root, everything works.
How can I make www.site.com/catalog?id=10 redirect to index.php even though catalog.php file exists?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Khirenko, 2014-03-26
@Satanpit

RewriteEngine On  
  
RewriteCond %{SCRIPT_FILENAME} !-d  
RewriteCond %{SCRIPT_FILENAME} !-f  

RewriteRule ^(.*)$ ./index.php?route=$1

Everything after www.site.com/ goes to $_GET['route']

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question