1.我明白爲什麼你試圖改變的.htaccess但是這可以解決很多簡單。恢復.htaccess文件回到Laravel標準
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule^index.php [L]
</IfModule>
2.將您的所有文件夾和文件的除了公衆,並確保他們的背後你的HTML文件夾中。
3.把你所有的公共文件夾和文件進行公用文件夾的和你的HTML文件夾
4.泰爾laravel通過改變服務器查找在HTML文件夾,而不是公共的。 PHP文件
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <[email protected]>
*/
$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/html'.$uri)) {
return false;
}
require_once __DIR__.'/html/index.php';
我覺得這個解決方案不是與你的htaccess亂搞簡單得多。你也可以確保所有的Laravel核心文件都不能通過url訪問。
其他問題你有(內部頁)
這可能是由於你的Apache不允許覆蓋與Laravels htaccess的
轉到您的服務器的命令行和訪問apache2.conf文件
cd /etc/apache2
納米打開apache2.conf文件
sudo nano apache2.conf
現在找到以下
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
更改爲
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
WriteOut的更改並退出nano。
重新啓動Apache
sudo service apache2 restart
現在應該工作:)
是喜是要刪除/公共形成你的網站...? –
嗨,糾正我,如果我錯了。您希望您的所有網址都來自example.com,而不是www.example.com。除了那些以/index.php結尾的url之外的所有url將被重定向到example.com? – TheChetan