Redirection of all requests to index.php does not work and gives an error, as I understand it, the problem is that Apache does not take into account the settings of my .htaccess file.

Here are the Apache settings from the httpd.conf file.

ServerRoot "c:/Server/bin/Apache24" Listen 80 LoadModule access_compat_module modules/mod_access_compat.so LoadModule actions_module modules/mod_actions.so LoadModule alias_module modules/mod_alias.so LoadModule allowmethods_module modules/mod_allowmethods.so LoadModule asis_module modules/mod_asis.so LoadModule auth_basic_module modules/mod_auth_basic.so LoadModule authn_core_module modules/mod_authn_core.so LoadModule authn_file_module modules/mod_authn_file.so LoadModule authz_core_module modules/mod_authz_core.so LoadModule authz_groupfile_module modules/mod_authz_groupfile.so LoadModule authz_host_module modules/mod_authz_host.so LoadModule authz_user_module modules/mod_authz_user.so LoadModule autoindex_module modules/mod_autoindex.so LoadModule cgi_module modules/mod_cgi.so LoadModule dir_module modules/mod_dir.so LoadModule env_module modules/mod_env.so LoadModule include_module modules/mod_include.so LoadModule isapi_module modules/mod_isapi.so LoadModule log_config_module modules/mod_log_config.so LoadModule mime_module modules/mod_mime.so LoadModule negotiation_module modules/mod_negotiation.so LoadModule rewrite_module modules/mod_rewrite.so LoadModule setenvif_module modules/mod_setenvif.so <IfModule unixd_module> User daemon Group daemon </IfModule> ServerAdmin admin@example.com ServerName localhost DocumentRoot "c:/Server/data/htdocs/" <Directory /> Options Includes Indexes FollowSymLinks AllowOverride All Allow from all </Directory> <Directory "c:/Server/data/htdocs/"> Options Indexes FollowSymLinks AllowOverride All Allow from all </Directory> <IfModule dir_module> DirectoryIndex index.html index.htm index.shtml index.php </IfModule> <Files ".ht*"> Require all denied </Files> ErrorLog "logs/error.log" LogLevel warn <IfModule log_config_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common <IfModule logio_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio </IfModule> CustomLog "logs/access.log" common </IfModule> <IfModule alias_module> ScriptAlias /cgi-bin/ "c:/Apache24/cgi-bin/" </IfModule> <Directory "c:/Apache24/cgi-bin"> AllowOverride None Options None Require all granted </Directory> <IfModule mime_module> AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps TypesConfig conf/mime.types AddType application/x-compress .Z AddType application/x-gzip .gz .tgz </IfModule> <IfModule proxy_html_module> Include conf/extra/proxy-html.conf </IfModule> <IfModule ssl_module> SSLRandomSeed startup builtin SSLRandomSeed connect builtin </IfModule> PHPIniDir "C:/Server/bin/PHP" AddHandler application/x-httpd-php .php LoadModule php5_module "C:/Server/bin/PHP/php5apache2_4.dll" 

Here is the link to the full config

Here are the contents of htaccess

 AddDefaultCharset utf-8 RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php 

Tell me, what's the problem?

  • Please show the contents of htaccess and describe what error occurs. - VenZell
  • An error occurs, the url is not found, suppose the main one opens, I press a button on the site and an action is stored in this button that should open the desired URL, this URL should be redirected to the php index and processed, but not redirected instead and just gives an error " The URL is not found, because there is really no file with such an address, but if it was processed by the controller, it would open what I need. - lupti_du
  • AddDefaultCharset utf-8 RewriteEngine on RewriteBase / RewriteCond% {REQUEST_FILENAME}! -F RewriteCond% {REQUEST_FILENAME}! -D RewriteRule ^ (. *) $ Index.php - lupti_du
  • Visually, everything looks right. AllowOverride all is present in the host, the module is being loaded, htaccess is correct. Try to look at the server logs, maybe it will catch on. - iosp
  • @lupti_du Add a code snippet with the button to the question. It will not be superfluous to indicate which framework you are using. - Kirill Korushkin

2 answers 2

And so?

  RewriteCond %{THE_REQUEST} ^[AZ]{3,9}\ /index\.php\ HTTP/ RewriteRule ^index\.php$ http://site.ru/ [R=301,L] 
  • doesn't work anyway - lupti_du

First you need to check whether htaccess is processed. To do this, save it with any text that does not make sense. If you get the 500th error, the file is processed.

Next, you need to check the server headers, for example, using https://bertal.ru/ or the Google Chrome developer tools - Network tab. It is possible (on hosting) that in the response headers as a server you will see not Apache, but nginx. Then you need to look at how nginx is configured. As a rule, he can search for the requested links physically in the file system.