的.htaccess重定向到语言子文件夹

编程入门 行业动态 更新时间:2024-10-21 04:15:47
本文介绍了的.htaccess重定向到语言子文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有什么:

  • 在安装有两种语言:德语和英语
  • 语言版本与子文件夹(www.domain/de/和www.domain/en /)
  • 管理
  • 机:安装TYPO3的4.5.4 / RealUrl
  • 启用mod_rewrite的作品

我想做什么:

  • 在重定向没有语言的子文件夹请求到德语版
  • 例如。 domain/any/test/folder/到domain/~~V 日 /所有/测试/文件夹
  • redirect requests without language subfolder to the German version
  • e.g. domain/any/test/folder/ to domain/de/any/test/folder

我的尝试:

RedirectMatch permanent ^/(?!(?:(?:de|en)/))(.*)$ /de/$1

发生的历史问题:

  • 所有的请求定向到domain/de/index.php~~V
  • 这导致了错误310(净值:: ERR_TOO_MANY_REDIRECTS)
  • 也许它没有使用TYPO3的htaccess的作品?

我的洞的.htaccess文件:

# Enable URL rewriting RewriteEngine On # Change this path, if your TYPO3 installation is located in a subdirectory of the website root. # RewriteBase / # Rule for versioned static files, configured through: # - $TYPO3_CONF_VARS['BE']['versionNumberInFilename'] # - $TYPO3_CONF_VARS['FE']['versionNumberInFilename'] # IMPORTANT: This rule has to be the very first RewriteCond in order to work! RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)\.(\d+)\.(php|js|css|png|jpg|gif|gzip)$ $1.$3 [L] # Stop rewrite processing, if we are in the typo3/ directory. RewriteRule ^(typo3/|t3lib/|fileadmin/|typo3conf/|typo3temp/|uploads/|favicon\.ico) - [L] # Redirect example/typo3 to example/typo3/index_re.php and stop the rewrite processing. RewriteRule ^typo3$ typo3/index_re.php [L] #301 redirection for language mode RedirectMatch permanent ^/(?!(?:(?:de|en)/))(.*)$ /de/$1 # If the file/symlink/directory does not exist => Redirect to index.php. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l # Main URL rewriting. RewriteRule .* index.php [L]

所以,我该怎么办?

推荐答案

怎么样的:

RewriteRule ^/?(?!de/|en/)(.*) /de/$1 [L,R=301]

更多推荐

的.htaccess重定向到语言子文件夹

本文发布于:2023-10-31 13:07:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546174.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件夹   重定向   语言   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!