【发布时间】:2019-01-01 22:49:01
【问题描述】:
我遇到了 URL 规范化问题,我想将 https://www.barreau.co/ar 重定向到 https://barreau.co/ar
请注意,以下 .htaccess 代码完美地将 https://www.barreau.co/ 重定向到 https://barreau.co/,但不能使用 Laravel 多语言应用程序添加的 /ar 或 /en。
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
Options -MultiViews
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.barreau\.co\/ar$
RewriteRule ^/?$ "http\:\/\/barreau\.co\/ar" [R=301,L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
如何使https://www.barreau.co/ 和https://www.barreau.co/ar 都正确重定向到非www URL?
【问题讨论】: