1
我最終試圖做的是將任何網址與www
轉發到它的非www等價物。所以https://www.baremetrics.io/academy會自動轉發到https://baremetrics.io/academy。通過.htaccess的www-removal轉發到index.php
相反,那些WWW網頁着https://baremetrics.io/index.php
而且我難倒原因。希望在我忽略的.htaccess文件中有一些東西。
下面是.htaccess文件中的內容baremetrics.io:
Header set Access-Control-Allow-Origin "*"
# Turn on the Rewrite Engine
RewriteEngine On
# If you're running in a subfolder (like http://example.com/statamic),
# add that here. E.g. /statamic/
RewriteBase/
# Protect your system files from prying eyes
RewriteRule ^(_app) - [F,L]
RewriteRule ^(_config) - [F,L]
RewriteRule ^(_cache) - [F,L]
RewriteRule ^(_content) - [F,L]
RewriteRule ^(_logs) - [F,L]
RewriteRule ^(admin/themes/[^/]*/(?:layouts|templates)) - [F,L]
RewriteRule ^(.*)?\.yml$ - [F,L]
RewriteRule ^(.*)?\.yaml$ - [F,L]
RewriteRule ^(.*/)?\.git+ - [F,L]
# This will prevent all .html files from being accessed.
# You may want to remove this line if you want to serve
# static files outside of Statamic
# RewriteRule ^(.*)?\.html$ - [F,L]
# Remove trailing slashes from your URL
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\/(\?.*)?$ $1$2 [R=301,L]
# Remove the index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
# Redirect old pages
RedirectMatch 301 ^/signup(.*)$ https://dashboard.baremetrics.io/signup$1
RedirectMatch 301 ^/dashboard(.*)$ https://dashboard.baremetrics.io$1
RedirectMatch 301 ^/stats(.*)$ https://dashboard.baremetrics.io/stats$1
RedirectMatch 301 ^/billing\.html(.*)$ https://dashboard.baremetrics.io/billing.html$1
RedirectMatch 301 ^/switch(.*)$ https://dashboard.baremetrics.io/switch$1
# No WWW
RewriteCond %{HTTP_HOST} !^baremetrics.io$ [NC]
RewriteRule ^(.*)$ https://baremetrics.io/$1 [L,R=301]
對於它的價值,該網站將被部署到Heroku的。
也許是因爲'RewriteRule ^(。*)$ index.php [QSA,L]'? – hjpotter92 2014-10-12 11:03:39
@ hjpotter92我試過刪除它,它仍然做同樣的事情。 – Shpigford 2014-10-12 11:10:24
@Prix:那就是訣竅!歡迎在此添加答案。 – Shpigford 2014-10-13 11:22:48