【发布时间】:2022-11-28 10:15:57
【问题描述】:
我有一个包含多种语言的 Modx 站点。 我正在尝试对网址进行重定向
https://example.com/fi/
至
https://example.com/fi/something
但我只想重定向“子文件夹”的根目录,而不是那个目录下的任何内容。 “example.com/fi/products”或其他任何内容。只是根 /fi/
当前的htaccess文件如下
RewriteEngine On
Options +FollowSymLinks
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
RewriteBase /
#Check for Fi
RewriteCond %{HTTP_HOST} .*example.com [NC]
RewriteCond %{HTTP:Accept-Language} ^fi [NC]
RewriteRule ^$ http://%{HTTP_HOST}/fi/ [L,R=301]
# Default to En
RewriteCond %{HTTP_HOST} .*example.com [NC]
RewriteRule ^$ https://%{HTTP_HOST}/en/ [L,R=301]
# Fix current links
RewriteCond %{HTTP_HOST} example.com [NC]
RewriteCond %{REQUEST_URI} !/en
RewriteCond %{REQUEST_URI} !/fi
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /en/$1 [L]
# The Friendly URLs part
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
如果我尝试
RedirectMatch 301 /fi /fi/something
我最终在 URL 中无限循环 /fi/something
【问题讨论】:
标签: apache .htaccess redirect mod-rewrite