我的项目有 MVC 结构:example.com/class/function/param
如果项目位于根文件夹或子文件夹中,我有http://example.com/或http://example.com/project/基于此。
我的目标是重定向:
http://example.com/ -> http://example.com/en/
http://example.com/project/ -> http://example.com/project/en/
http://example.com/**en**/应替换为等效语言(例如:/ de /、/ ru /、...),因此在伪代码中:
{base_url}/{lang}/{class}/{function}/{param}
定义http://example.com为相对路径!
然后我可以选择第一段 url ( /en/ ) 并使用我的函数更改语言。
我当前的.htaccess文件:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
# Prevent file browsing
Options -Indexes
编辑:
考虑Router.php类来处理 URL 重写......