When you use the advanced Yii application template, you will need to set up two separate domains and set their web root to point to frontend/web and backend/web, respectively.
In other words : the root of the routes (the application root) is the web directory.
If you are not able to set up the root properly, then you will need to use a application template that allows you to use the root directory as web root…
I am sorry, but this is “You have a problem with Windows? - Reinstall Windows!” kind of answer.
I would recommend you to avoid this way of educating people in a future. Neither informative nor helpful.
There must be some way to rewrite.
It is both informative and helpful!
Perhaps not to you - who made the mistake of not giving enough details - but other people are going to find it very enlightening, especially when they come across it via the forum search function
BTW are you using custom .htaccess file already ? I think that both the basic and the advanced yii2 templates do not have /web in url in default configuration. Post here your current .htaccess file (and your apache config if you have control over apache at hosting server)
I never had web in routes or url. First properly setup folder structure
As example:
apache2
htdocs
------ yii2 // under htcdocs
yii2up // same level as apache2
And index.php
<?php
defined('DS') || define('DS', DIRECTORY_SEPARATOR);
// comment out the following two lines when deployed to production
//defined('YII_DEBUG') or define('YII_DEBUG', true);
//defined('YII_ENV') or define('YII_ENV', 'dev');
require __DIR__ . '/../../yii2up/vendor/autoload.php'; // point to correct path
require __DIR__ . '/../../yii2up/vendor/yiisoft/yii2/Yii.php'; // same here
$config = require __DIR__ . '/../../yii2up/config/web.php';
(new yii\web\Application($config))->run();
htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteBase /yii2/ # your correct folder
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
Can you sometimes catch the idea, that you approach EXISITING setup - a running application serving already 100.000 people and nobody is going to change it’s directory tree at this moment?
Then I would give up. I would be satisfied with the existing url `http://mydomain/frontend/web’. IMO, it’s not a good idea to change the url of an existing app once it has started to work as a production.
You’d better forget it.
Or if you really want to get rid of “web”, you should try to elaborate your current setup … the current directory structure and the httpd configuration. You have been neither informative nor helpful for us to understand your problem so far.
Oh, what an honor … but I’m not @samdark.
And you haven’t answered my question. What is your directory structure and what is your current httpd configuration?
And, I’m afraid you can not change the url rule for the RESTful API while keeping the one for the ordinary web app … I’m not sure. But you have to give us more information, anyway.
So I am sorry for calling you with a wrong name - excuse me, please!
And according configuration - the virtual server points to a single “top” directory where entire application is stored including vendor directory… Not good, but so it is…
I have just deleted the last post of yours. You should not expose all the things in public! You have to be cautious about the security of your web app.
What I wanted to know is only the current configuration of your Yii application.
OK, thank you for caustion but… What do you actually mean by “current configuration of my Yii application” ? Do you really need all configuration files - what for?
This is a virtual private server with PHP FastCGI/FPM configuration. I do not direct access to the configuration - it is managed by an external company.
Consequently - a server “web root” is a directory where entire Yii advanced is stored (so the directory containing “backend”, “frontend”, “common”, “console”, “autorestapi”, etc.
<FilesMatch “(.(bak|config|sql|fla|psd|ini|log|sh|inc|swp|dist)|~)$”>
# block accesses to backup/source files
Order allow,deny
Deny from all
Satisfy All
Then, the frontend and backend URL rules are complex, but generally they are only used to setup modules.