【发布时间】:2015-03-11 09:04:55
【问题描述】:
我有一个 Laravel 4 应用程序,它在 XAMPP 上本地运行良好。
我已将其上传到域 - domain.com -(由 godaddy 托管)并将其放在 hcr 文件夹中。
在 hcr/app/config/app.php 我有
'url' => 'http://domain.com/hcr',
在 hcr/public/.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>
从 url 中删除 public。
我可以访问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”?
【问题讨论】:
标签: apache .htaccess mod-rewrite laravel-4