.htaccess -> Web 文件夹中的 index.php(url 必须是 web/)
.htaccess -> index.php in web folder (url has to be web/)
我在设置 .htaccess 文件时遇到问题。在我的 web 文件夹中(在我项目的 root 中)我有 index.php 。现在我必须去 mydomain.com/web/ 查看我的 index.php .
我在我的 /web 文件夹中添加了一个 .htacces 文件,但它不起作用。这是我的 .htaccess 文件的内容:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
我做错了什么?
为此您可以拥有 2 个 .htaccess:
root .htaccess (比web高一级):
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^((?!web/).*)$ web/ [NC,L]
/web/.htaccess:
RewriteEngine On
RewriteBase /web/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php [L]
你试过了吗RewriteBase
?
RewriteBase /web/
这个post也很有用
- How does RewriteBase work in .htaccess
我在设置 .htaccess 文件时遇到问题。在我的 web 文件夹中(在我项目的 root 中)我有 index.php 。现在我必须去 mydomain.com/web/ 查看我的 index.php .
我在我的 /web 文件夹中添加了一个 .htacces 文件,但它不起作用。这是我的 .htaccess 文件的内容:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
我做错了什么?
为此您可以拥有 2 个 .htaccess:
root .htaccess (比web高一级):
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^((?!web/).*)$ web/ [NC,L]
/web/.htaccess:
RewriteEngine On
RewriteBase /web/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php [L]
你试过了吗RewriteBase
?
RewriteBase /web/
这个post也很有用
- How does RewriteBase work in .htaccess