我一直在寻找周围的答案,这一点,并不能找到任何人与我确切的问题,并希望其他人遇到过这个问题。
我已经安装Laravel在本地使用的是虚拟主机,它是安装在根目录下。我现在不得不搬到这个安装到另一台服务器在 http://domain.com/~username
,我所有的文件都在 /〜用户名/
和我使用的.htaccess
从 http://domain.com/~username 。
我也把我的正确路径和 app.php
我的网站的网址。
几乎一切工作,除了我的路线。
如果我浏览到 http://domain.com/~username
我收到了 NotFoundHttpException
这是我的路线,我的主页:
路线::得到('/',函数(){...});
如果我把它改为
路线::得到('/〜用户名',函数(){...});
它显示我的主页。这不正是理想的哈克和亲切,再加上有很多的不只是网页更多的问题。
我有,因为 Laravel认为它是安装在根文件夹中的其他问题,pretty的每样东西,而不是 /〜用户名/
。
我的问题是我怎样才能Laravel看到它安装到 http://domain.com/~username/
和NOT http://domain.com/
?
编辑:添加.htaccess文件
在根我现在的.htaccess文件(/〜用户名)
< IfModule mod_rewrite.c>
RewriteEngine叙述上
的RewriteBase /〜用户名/
的RewriteCond%{THE_REQUEST} ^ GET /公/ [NC]
重写规则^公共/(.*)$ $ 1 [L,R = 301,NE]
重写规则^((?公共/).*)$公共/ $ 1 [L,NC]
< / IfModule>
和中/公共.htaccess文件
< IfModule mod_rewrite.c>
选项-MultiViews
RewriteEngine叙述上
的RewriteBase /〜用户名/
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{} REQUEST_FILENAME!-f
重写规则。的index.php [L]
< / IfModule>
解决方案
我可能没有正确地理解你的问题,但这里是我的解决方案。
转到/bootstrap/paths.php,并更改为:
返回阵列(
应用程序=> __DIR __。'〜用户名/../应用程序,
公共=> __DIR __。'〜用户名/../公众,
'基地'=> __DIR __。'〜用户名/ ..',
'存储'=> __DIR __。'〜用户名/../应用程序/存储,
)
我不知道这是否会工作。我还没有尝试过。
I've been searching around for an answer to this and can't find anyone with my exact problem and was hoping someone else has had this issue.
I had Laravel installed locally using a vhost, and it was installed at the root. I've now had to move this install to another server at http://domain.com/~username
, all my files are in /~username/
and I'm using .htaccess
to access the public
folder from http://domain.com/~username
.
I've also set my paths correctly and my site URL in app.php
.
Everything almost works except for my routes.
If I navigate to http://domain.com/~username
I get a NotFoundHttpException
This is my route for my homepage:
Route::get('/', function() { ... });
if I change it to
Route::get('/~username', function() { ... });
it shows me the homepage. This isn't exactly ideal and kind of hacky, plus there's a lot more issues than just the homepage.
I'm having other issues with pretty much everything because Laravel thinks it's installed in the root folder, and not /~username/
.
My question is how can I get Laravel to see that it's installed to http://domain.com/~username/
and NOT http://domain.com/
?
EDITS: adding .htaccess files
My current .htaccess file in root (/~username)
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /~username/
RewriteCond %{THE_REQUEST} ^GET /public/ [NC]
RewriteRule ^public/(.*)$ $1 [L,R=301,NE]
RewriteRule ^((?!public/).*)$ public/$1 [L,NC]
</IfModule>
and the .htaccess file in /public
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /~username/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
</IfModule>
解决方案
I might not have understood your question properly but here is my solution.
Go to /bootstrap/paths.php and change to:
return array(
'app' => __DIR__.'~username/../app',
'public' => __DIR__.'~username/../public',
'base' => __DIR__.'~username/..',
'storage' => __DIR__.'~username/../app/storage',
)
I'm not sure if this will work. I haven't tried it.