2019-01-01 14:20
浏览 143


I got a URL Canonicalization issue and I want to redirect to

Please note that the following .htaccess code redirects to perfectly, but not with the /ar or /en that the Laravel multilanguage applications add.

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews -Indexes
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]

How can I make both and redirect to non-www URLs correctly?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • dongtang5057 2019-01-01 14:49

    There's need to specify the locale imo.

    Can you try this?

    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

    I tried it in a local environment with a fresh Laravel installation. It works fine. Make sure you also have mod_rewrite enabled and to restart your apache after doing the change.

    解决 无用
    打赏 举报

相关推荐 更多相似问题