Answer the question
In order to leave comments, you need to log in
How to generate CNC in yii2 without web/ in address bar?
Hello!
I'm trying to get rid of the web folder in the address bar in the yii2 project and following links.
I'll write down the steps, what I did and what doesn't work:
To begin with, I'll clarify that the basic distribution kit is in the localhost folder, and basic has been renamed to the site name. In short, in the browser the site is accessed like this:
localhost/sitename/web
What I did:
1. In the web folder I created .htaccess with the content (taken from the yii documentation):
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
# If a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward it to index.php
RewriteRule . index.php
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
],
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/(web)
RewriteRule (.*) /web/$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /web/index.php
Answer the question
In order to leave comments, you need to log in
If your APACHE looks into the localhost folder, then rebuild it so that it looks directly into the WEB folder and you will be happy ..
1)
htaccess in WEB folder.
# Mod_Autoindex
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)?$ index.php
In config:
'request' => [
'baseUrl' => ''
],
possibly you will need to reconfigure the routes depending on what is now written
2) The second option, you can specify in the virtual host settings apache DocumentRoot /web/ then you don’t need to do anything else
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question