本文介绍了的.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重定向到语言子文件夹
发布评论