2

私が持っているもの:

  • ドイツ語と英語の2つの言語がインストールされています
  • 言語バージョンはサブフォルダー(www.domain.com/de/およびwww.domain.com/en/)で管理されます
  • マシン:Typo3 4.5.4/RealUrlがインストールされています
  • mod_rewriteが有効になっている作品

私がやりたいこと:

  • 言語サブフォルダなしでリクエストをドイツ語バージョンにリダイレクトする
  • 例:domain.com/any/test/folder/からdomain.com/ de / any / test / folder

私が試したこと:

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

発生する問題:

  • すべてのリクエストはdomain.com/de/index.phpに送信されました
  • エラー310が発生しました(net :: ERR_TOO_MANY_REDIRECTS)
  • 多分それはTypo3のhtaccessエントリで失敗しますか?

私の穴.htaccess-file:

# 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 http://example.com/typo3 to http://example.com/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]

それで、なにかお手伝いできますか?

4

3 に答える 3

4

これはどうですか:

RewriteRule ^/?(?!de/|en/)(.*) /de/$1 [L,R=301]
于 2012-04-08T18:17:27.267 に答える
2

次のようなもっと単純なものを使ってみませんか。

# if user didn't specify a valid language subfolder
RewriteCond %{REQUEST_URI} !^/(en|de)/
# redirect user to default language subfolder
RewriteRule ^(.*)$ /de/$1 [L,R=301]
于 2012-04-08T18:26:16.007 に答える
0

realUrl構成でこの動作を構成できるため、実際にはhtaccesを使用する必要はありません。構成配列でこの部分を定義するだけです。

    'preVars' => array(
      array(
        'GETvar' => 'L',
        'valueMap' => array(
            'de' => '0',
            'en' => '1',
            'fr' => '2',
            ),
        'valueDefault' => 'de',
        ),
),

これにより、.. / de/..へのリダイレクトが提供されます。

于 2012-05-04T13:18:33.550 に答える