【发布时间】:2019-04-30 19:09:03
【问题描述】:
我的目录结构是这样的,我的文档根是/
/
.htaccess
/public
这一切都在我的本地 xampp 服务器上。 服务器设置为侦听 mydomain.local,并且在我的 hosts 文件中,我已将 mydomian.local 指向 localhost。
我正在使用以下 .htaccess 代码,当使用 mydomain.local 作为地址时它可以正常工作。
我遇到的问题是当我使用 localhost/mydomain 作为地址时它不起作用
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ public/index.php?path=$1 [NC,L,QSA]
当使用 localhost/mydomain 作为地址时,如何让它工作?
这是因为我正在尝试注册 service worker,但它们只能通过 https 或 localhost 工作。
提前致谢
【问题讨论】:
-
你能在 url 重写中添加预期的行为吗?您的意思是 locahost/mydomain = mydomain.local 还是等待 localhost/public/index.php?path=mydomain 这将是您设置的逻辑结果。除此之外,您使用的是虚拟主机还是别名?
-
@Bertrand localhost/mydomain/page = mydomain.local/page = mydomain.local/index.php?path=page