I transfer the site and ran into a problem: the CNC stopped working, and since the site is tied to them, then its functionality is badly damaged - the main page opens all the time, regardless of the selected menu item. Everything worked on the old hosting, locally on OpenServer it still works, but when transferred to VDS ... alas. Apache 2.4.6, PCP 5.4, On other sites on this server there are no problems with mod_rewrite, but there the CNC are more adequately implemented, and here ... Like this:

Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^site\.ru$ [NC] RewriteRule ^(.*)$ http://site.ru/$1 [R=301,L] RewriteBase / php_flag register_globals on ErrorDocument 404 /404.html php_flag display_errors On php_flag display_startup_errors On #AddDefaultCharset windows-1251 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^priem/([0-9]+)/?$ index.php?menu=priem&month=$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^catalog/$ index.php?catalog=ok [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^catalog/([a-zA-Z_0-9]+)/$ index.php?cat=$1&catalog=ok [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^catalog/([a-zA-Z_0-9]+)$ index.php?cat=$1&catalog=ok [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^catalog/([a-zA-Z_0-9]+)/([a-zA-Z_0-9]+).html index.php?cat=$1&catalog=ok&tov=$2 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^catalog/([a-zA-Z_0-9]+)/([a-zA-Z_0-9]+)/([a-zA-Z_0-9]+).html index.php?cat=$1&pages=$2&tov=$3&catalog=ok [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^catalog/([a-zA-Z_0-9]+)/([a-zA-Z_0-9]+)/?$ index.php?cat=$1&pages=$2&catalog=ok [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-zA-Z_0-9]+)/([a-zA-Z_0-9]+)/([a-zA-Z_0-9]+).php index.php?menu=$1&pages=$2&doc=$3 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-zA-Z_0-9]+)/([a-zA-Z_0-9]+)/([a-zA-Z_0-9]+).html index.php?menu=$1&pages=$2&doc=$3 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-zA-Z_0-9]+)/([a-zA-Z_0-9]+)/?$ index.php?menu=$1&pages=$2 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-zA-Z_0-9]+)/([a-zA-Z_0-9]+).html index.php?menu=$1&doc=$2 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-zA-Z_0-9]+)/?$ index.php?menu=$1 [L] 

Server support for two days could only give birth:

In .htaccess there are many duplicate rules, due to which such errors occur. In this case, it is recommended to contact the site developer directly.

A few hours of dancing with a tambourine and commenting line by line - did not give anything. Mod_rewrite itself is enabled and phpinfo () sees it. I understand that the dog is buried somewhere here, but I cannot find it. Please tell in which direction to dig. Thank!

  • one
    Why do you think the problem is with mod_rewrite? It works, once index.php is opened (it is also the target of all redirections). You may not have a branch in index.php. PS php_flag register_globals on can delete it, in php 5.4 it is not. - Visman
  • The idea is interesting, I'll check it out. Only then why does the local copy work properly on the same server settings? - Konstantin
  • one
    Add to the beginning of index.php line var_dump($_GET); and check if mod_rewrite works by adding the required get variables with values. - Visman
  • checked works correctly. displays, for example, array (1) {["menu"] => string (8) "new_year"} at site.ru/new_year/, but it still displays the same main page = \ - Konstantin
  • one
    You would look at the error log on the server that they write there. You have a problem with the router in php, not in .htaccess. - Visman Nov.

1 answer 1

The problem just turned out to be tied to register_globals on , I don’t know how it worked on the old hosting, but rolling back the php version to 5.3 on the new server and adjusting the router function a little, everything was up to the mark

  • one
    As a temporary solution - you can use. But I advise you to rewrite the site code without using register_globals on Read this php.net/manual/ru/security.globals.php from php developers. - Visman