Now the site has a redirect via .htaccess from any pages on /index.php except robots.txt

RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} !^/robots\.txt$ RewriteRule ^(.*)$ index.php [L,QSA] 

but when I try to go to the root of the site (/), it naturally goes to index.php and then again redirects and loops. How to disable redirect for root ( site.com/ ) and index.php file ( site.com/index.php )?

UPD

Did so:

 RewriteEngine On RewriteBase / RewriteRule ^about$ /pages/about.php RewriteRule ^contact$ /pages/contact.php RewriteRule ^portfolio$ /pages/portfolio.php RewriteRule ^home$ /pages/index.php RewriteRule ^blog$ /pages/blog.php [L] 

And in the engine file I made a check: if the main one is a redirect to / home

  • And how can a 404 mistake do this if? - Shevsky

1 answer 1

Is it not easier to make the transition only by reference or to deliver.

 <script>location.href='site_name.ru/index.php';</script> 

?

Go to links only:

 $block = $_SERVER['HTTP_REFERER']; if(strlen($block)>1){ // содержание сайта }else{ echo"<script>location.href='site_name.ru/index.php';</script>"; } 
  • And why not the header, but such a perversion? xD - Shevsky