【发布时间】:2017-07-13 05:15:11
【问题描述】:
我的 htacess 文件有问题。
我有一个 php mvc 系统,根目录看起来像 公共[文件夹] 应用程序 [文件夹] 访问
第一个htaccess读取
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
这是从我假设的 url 中删除 public ?
我拥有的第二个 htaccess 文件位于公共目录中,其中包含启动 php 应用程序的 index.php 文件
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/public) /$1 [L]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
这是为了强制 url 转到 https 而不是 http,我遇到的问题是,如果将 url 作为http://example.com 输入到 url 栏中并且重写发生,它将带我到 https://example.com/public,如果发生这种情况,我正在尝试从 url 中删除公共目录,任何帮助都会非常感激。
干杯 瑞恩
【问题讨论】:
-
非常感谢,我什至没有考虑将文档根设置为公开。写这个作为答案并且我不接受它,我一直很愚蠢(第一个 MVC 应用程序)
-
添加评论作为答案
标签: php apache .htaccess mod-rewrite