2015-01-13 39 views
0

我有一个Laravel 4应用程序,它在XAMPP本地工作正常。在URL中没有“公共”的子文件夹中的Laravel 4

我已经将它上传到域名 - domain.com - (与godaddy一起),并将其放置在hcr文件夹中。

HCR /应用/配置/ app.php我有

'URL'=> 'http://domain.com/hcr',

HCR /公共/ htaccess的我有

<IfModule mod_rewrite.c> 
    <IfModule mod_negotiation.c> 
     Options -MultiViews 
    </IfModule> 

    RewriteEngine On 
    RewriteBase /hcr 

    # Redirect Trailing Slashes... 
    RewriteRule ^(.*)/$ /$1 [L,R=301] 

    # Handle Front Controller... 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule^index.php [L] 
</IfModule> 

,并在HCR /的.htaccess我有

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase /hcr 
    RewriteRule ^(.*)$ public/$1 [L] 
</IfModule> 

删除public from url。

我可以访问http://domain.com/hcr/并加载页面(没有样式,图像,...)。 但页面,图像,CSS,JS,...的所有其他链接都是错误的。 例如,它们链接到

http://domain.com/css/styles.css

而不是链接到

http://domain.com/hcr/css/styles.css

即 “HCR” 缺少从所有链接。

如果我去

http://maintimeline.com/hcr/public/

一切工作正常,但我的网址,这是我想删除具有“公共”。

那么,如何从.htaccess文件的url中删除“public”呢?

回答

1

按照这些简单的步骤

1. move all files from public directory to root /laravel/ now, no need of public directory, so optionally you can remove it now 
2. now open index.php and make following replacements 

require DIR.'/../bootstrap/autoload.php'; 

to 

require DIR.'/bootstrap/autoload.php'; 

and 

$app = require_once DIR.'/../bootstrap/start.php'; 

to 

$app = require_once DIR.'/bootstrap/start.php'; 

3. now open bootstrap/paths.php and change public directory path: 
'public' => DIR.'/../public', 

to 

'public' => DIR.'/..', 
+0

感谢您的答复。这是另一个解决方案,从url中摆脱“公共”文件夹。我对此很清楚。但那不是我想要的。我想让它与.htaccess文件一起工作,并理解它为什么现在不能正常工作...... – nunomira

相关问题