Apache 重写 Laravel/public [英] Apache rewrite for Laravel /public
问题描述
对此我很抱歉,但我的 htdocs 根目录错误,我无法更改.所以我必须让它在 /public
文件夹中工作.
I am sorry about this, but my htdocs root is wrong and I can't change that. So I have to make it work in the /public
folder.
我使用普通的 Laravel .htaccess 文件并进行以下重写:
I use the normal Laravel .htaccess file with the following rewrite:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
如果我打开 http://kemtime2_neu.pr.domain.de/public
我被重定向到 http://kemtime2_neu.pr.domain.de/public/http://kemtime2_neu.pr.domain.de/public/login
If I open http://kemtime2_neu.pr.domain.de/public
I get redirected to http://kemtime2_neu.pr.domain.de/public/http://kemtime2_neu.pr.domain.de/public/login
我该如何解决这个问题?
How can I fix this?
我很想让它从 http://kemtime2_neu.pr.domain.de/
工作,但让它与 http://kemtime2_neu.pr.domain.de 一起工作/public/
没问题.
I would love to make it work from http://kemtime2_neu.pr.domain.de/
but getting it to work with http://kemtime2_neu.pr.domain.de/public/
would be fine.
推荐答案
我部分解决了.如果我在根目录中有一个 .htaccess 而不是 /public
with
I solved it partly. If I have a .htaccess in the root instead of /public
with
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /public/index.php/$1 [L]
我可以打开 http://kemtime2_neu.pr.domain.de/login
但图片和 css 仍然是错误的.我需要先检查 /public
中是否存在文件.我认为这是一个新问题.
I can open http://kemtime2_neu.pr.domain.de/login
but the images and css is still wrong. I need to check first if the files exist in /public
. I think this is a new question.
这篇关于Apache 重写 Laravel/public的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!