2
我應該首先說我不是.htaccess
的專家,並且我所做的一切都來自我遵循的教程。鞏固.htaccess並修復問題
我已經編輯股票標準.htaccess
文件附帶Laravel包括線是
- 從URL中移除公共
- 力HTTPS
- 重定向到www.mysite.com mysite的請求。 com
我目前遇到的問題是,當我訪問路線mysite.com/sitemap
或www.mysite.com/sitemap
時,它會生成一個新網站地圖,然後重定向到mysite.com/index.php
有效地擺脫Laravel要修復的漂亮的URL。
這是我.htaccess
文件在我的公開目錄:
<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]
# Redirect www.mysite.com to mysite.com
RewriteBase/
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# Force SSL
RewriteCond %{HTTPS} !=on
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
這是.htaccess
文件在我的根目錄
# Remove public
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
這是我routes.php
處理sitemap
路線
Route::get('sitemap', function(){
// create new sitemap object
$sitemap = App::make("sitemap");
// add items to the sitemap (url, date, priority, freq)
$sitemap->add(URL::to('/'), '2015-11-14T20:10:00+02:00', '1.0', 'monthly');
$sitemap->add(URL::to('getcv'), '2015-11-14T12:30:00+02:00', '0.9', 'monthly');
// generate your sitemap (format, filename)
$sitemap->store('xml', 'sitemap');
// this will generate file sitemap.xml to your public folder
return redirect('/');
});
我的問題是,如何才能讓這個mysite.com/sitemap
或www.mysite.com
仍然遵循所有的規則在我.htaccess
同時重定向到mysite.com
繼sitemap
路由,而不是去mysite.com/index.php
後?
完美,謝謝!我不認爲這個設置有什麼問題,但是沒有足夠的經驗來使用'.htaccess'來實現我需要對它進行重新排序。 – James