gpt4 book ai didi

apache - 重定向 301 htaccess 仅适用于斜线 Laravel

转载 作者:行者123 更新时间:2023-12-01 23:08:38 33 4
gpt4 key购买 nike

我的重定向出现问题。

我想将domain.ir重定向到domain.com好吧,但是什么时候

我希望从domain.ir重定向到domain.com的所有请求仅在我用斜杠完成网址时才有效

domain.ir/wiki/--->domain.com/wiki

但是

domain.ir/wiki --->domain.com/index.php

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>

RewriteEngine On

RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(.*?)index\.php$ /$1 [L,R=302,NC,NE]

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

RewriteCond %{HTTP_HOST} ^www.digibaj.ir$ [NC]
RewriteRule ^(.*)$ http://digibaj.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^digibaj.ir$ [NC]
RewriteRule ^(.*)$ http://digibaj.com/$1 [R=301,L]

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

Digibaj.com

有什么想法吗?!

最佳答案

像这样重构和重新排序您的规则:

Options -MultiViews
RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.digibaj\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^(www\.)?digibaj\.ir$ [NC]
RewriteRule ^(.*)$ http://digibaj.com/$1 [R=301,L]

RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(.*?)index\.php$ /$1 [L,R=302,NC,NE]

# Redirect Trailing Slashes for non-directories
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

请务必在清除浏览器缓存后进行测试。

关于apache - 重定向 301 htaccess 仅适用于斜线 Laravel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33095567/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com