R
R
Ruslan2015-12-19 14:15:19
PHP
Ruslan, 2015-12-19 14:15:19

What is the error when redirecting to index.php in .htaccess?

The problem is as follows: there is a local OpenServer server hosting the yii2sitestudy1.loc site. That is, in the domains folder there is yii2sitestudy1.loc, and in this folder there is yii2sitestudy1.loc\frontend\web\index.php. I need that when I enter yii2sitestudy1.loc/ in the address bar of the browser, yii2sitestudy1.loc\frontend\web\index.php opens.
I myself am not familiar with the capabilities of .htaccess and how to do it in it, I found the
following solution on the net: put .htaccess with the following code in the root folder of the yii2sitestudy1.loc site:

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On
</IfModule>

<IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_URL} ^/.*    
    RewriteRule ^(.*)$ frontend/web/$1 [L]
    
    RewriteCond %{REQUEST_URL} !^/frontend/web/
    RewriteCond %{REQUEST_FILENAME} !-f [OR]
    RewriteCond %{REQUEST_FILENAME} !-d
    
    RewriteRule ^.*$ frontend/web/index.php
    
</IfModule>

and in the yii2sitestudy1.loc\frontend\web\ folder put .htaccess with the following code:
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

At first this code worked, but then it started throwing an error:
Server error!
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.
If you think this is a server error, please contact the webmaster.
Error 500
yii2sitestudy1.loc
12/19/15 12:51:07
Apache/2.2.31 (Win32)
help identify where the error was made

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
OnYourLips, 2015-12-19
@OnYourLips

Error in specifying the public directory of the web server incorrectly.
/ should initially point to \frontend\web\ in the webserver settings, not via .htaccess.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question