假设我有网址
http://www.example.com/se/products/details/23
http://www.example.com/se/company/about
http://www.example.com/se/customers/europe/john-doe
etc.
我希望他们rewrite
到
http://www.example.com/en/products/details/23
http://www.example.com/en/company/about
http://www.example.com/en/customers/europe/john-doe
etc
这意味着无论使用何种语言,它们都会重新归结为en
,他们会在地址栏中看到各自的语言,但页面是来自“en”的服务器
我的规则看起来像这样
# Pass through the original path as a query parameter, and retain the existing parameters.
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* framework/main.php?url=%1 [QSA]
RewriteRule ^se/(.+?)\/?$ /en/$1 [L]
该项目基于SilverStripe
框架。
这不起作用,显示404页面找不到错误
我们怎么做?
答案 0 :(得分:1)
重新排序您的规则并将其设为:
RewriteEngine On
RewriteRule ^se(/.*)?$ en$1 [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ framework/main.php?url=%{REQUEST_URI} [L,QSA]
答案 1 :(得分:0)
尝试这样,
Options -MultiViews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^se/(.+?)\/?$ /en/$1 [L]
或
RewriteRule ^se/(.*) en/$1 [L]