【发布时间】:2016-06-05 13:20:17
【问题描述】:
我希望这里有人能够帮助我,因为我正在慢慢失去理智,试图让重写规则在 HTAccess 中工作。
我只需要发生 3 件事。
1) 所有 www.流量应该去非www。
2) 所有非 https 的流量都应该转到 https。
3) 所有的 URL 都应该通过这些重写来保留。
我在网上尝试了无数不同的示例(以及我自己对它们的拙劣变体),但没有达到我想要的结果。该网站使用 Joomla,因此 Joomla 包含相当多的废话作为标准,但我很确定这些都不会干扰它。
使用当前的 HTAccess 'www.'正在被删除,用户被强制 https,但 URL 正在丢失。
提前感谢您的帮助!
我的 HTAccess 文件在这里:
AddHandler application/x-httpd-php53 .php
ErrorDocument 401 "Authorisation Required"
##
# Joomla Crap START
##
RewriteEngine On
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule .* index.php [F]
RewriteBase /
#RewriteCond %{HTTP_HOST} !^www\.
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
##
# Joomla Crap END
##
# rewrite www.mywebsite.co.uk > mywebsite.co.uk
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# rewrite http > https
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
Redirect 301 /~fitspace https://mywebsite.co.uk
RedirectMatch 301 ^/index.php/(.*)$ https://mywebsite.co.uk/$1
【问题讨论】:
标签: apache .htaccess mod-rewrite joomla