如何在 Yii2 高级中从 url 中删除 frontend/web 以便在我使用 Url::to 时它不会出现
How to remove frontend/web from url in Yii2 advanced so that it doesn't appear when I use Url::to
我已经编写了 .htaccess 文件来防止 frontend/web 出现在 url 中,但是当我通过 Url::to 设置链接时它出现在 url 中。
这是我在根目录中的 .htaccess:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
</IfModule>
<IfModule mod_rewrite.c>
# deal with admin first
RewriteCond %{REQUEST_URI} ^/(admin)
RewriteRule ^admin/assets/(.*)$ backend/web/assets/ [L]
RewriteRule ^admin/css/(.*)$ backend/web/css/ [L]
RewriteCond %{REQUEST_URI} !^/backend/web/(assets|css)/
RewriteCond %{REQUEST_URI} ^/(admin)
RewriteRule ^.*$ backend/web/index.php [L]
RewriteCond %{REQUEST_URI} ^/(assets|css|js|images)
RewriteRule ^assets/(.*)$ frontend/web/assets/ [L]
RewriteRule ^css/(.*)$ frontend/web/css/ [L]
RewriteRule ^js/(.*)$ frontend/web/js/ [L]
RewriteRule ^images/(.*)$ frontend/web/images/ [L]
RewriteRule ^(.*)$ frontend/web/ [L]
RewriteCond %{REQUEST_URI} !^/(frontend|backend)/web/(assets|css|js)/
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ frontend/web/index.php
</IfModule>
这是 frontend/web 目录中的 .htaccess 文件:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
请帮帮我,我不知道该怎么做。
在 Apache 的 httpd.conf 文件或虚拟主机配置中使用以下配置。请注意,您应该将 path/to/frontend/web
替换为 frontend/web
.
的实际路径
# Set document root to be "frontend/web"
DocumentRoot "path/to/frontend/web"
<Directory "path/to/frontend/web">
# use mod_rewrite for pretty URL support
RewriteEngine on
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
# ...other settings...
</Directory>
将以下行添加到您的 .htaccess 文件中,并将 /to/base/path/ 替换为您的项目目录路径
RewriteCond %{REQUEST_URI} ^/to/base/path/
RewriteRule ^(.*)$ frontend/web/ [L]
你对基本的东西有很多疑问。 this 怎么样
你可以在其中看到很多 ccs 的东西,而不仅仅是
我已经编写了 .htaccess 文件来防止 frontend/web 出现在 url 中,但是当我通过 Url::to 设置链接时它出现在 url 中。 这是我在根目录中的 .htaccess:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
</IfModule>
<IfModule mod_rewrite.c>
# deal with admin first
RewriteCond %{REQUEST_URI} ^/(admin)
RewriteRule ^admin/assets/(.*)$ backend/web/assets/ [L]
RewriteRule ^admin/css/(.*)$ backend/web/css/ [L]
RewriteCond %{REQUEST_URI} !^/backend/web/(assets|css)/
RewriteCond %{REQUEST_URI} ^/(admin)
RewriteRule ^.*$ backend/web/index.php [L]
RewriteCond %{REQUEST_URI} ^/(assets|css|js|images)
RewriteRule ^assets/(.*)$ frontend/web/assets/ [L]
RewriteRule ^css/(.*)$ frontend/web/css/ [L]
RewriteRule ^js/(.*)$ frontend/web/js/ [L]
RewriteRule ^images/(.*)$ frontend/web/images/ [L]
RewriteRule ^(.*)$ frontend/web/ [L]
RewriteCond %{REQUEST_URI} !^/(frontend|backend)/web/(assets|css|js)/
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ frontend/web/index.php
</IfModule>
这是 frontend/web 目录中的 .htaccess 文件:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
请帮帮我,我不知道该怎么做。
在 Apache 的 httpd.conf 文件或虚拟主机配置中使用以下配置。请注意,您应该将 path/to/frontend/web
替换为 frontend/web
.
# Set document root to be "frontend/web"
DocumentRoot "path/to/frontend/web"
<Directory "path/to/frontend/web">
# use mod_rewrite for pretty URL support
RewriteEngine on
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
# ...other settings...
</Directory>
将以下行添加到您的 .htaccess 文件中,并将 /to/base/path/ 替换为您的项目目录路径
RewriteCond %{REQUEST_URI} ^/to/base/path/
RewriteRule ^(.*)$ frontend/web/ [L]
你对基本的东西有很多疑问。 this 怎么样 你可以在其中看到很多 ccs 的东西,而不仅仅是