我想重定向所有路径:
myurl.com/worldwide/en
myurl.com/worldwide/pt
myurl.com/worldwide/de
为:
myurl.com/worldwide/index.php?lang=en
myurl.com/worldwide/index.php?lang=pt
myurl.com/worldwide/index.php?lang=de
要明确/worldwide
其实理想情况下我想保留原始网址(例如myurl.com/worldwide/de
)但是加载相同的php文件作为参数的语言目录但是不确定这是否可行?
由于
答案 0 :(得分:8)
使用此代码
RewriteEngine On
RewriteBase /worldwide/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?lang=$1 [L,QSA]
如果这对你有帮助,请告诉我
答案 1 :(得分:0)
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L,NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php !-f
RewriteRule ^(.+)$ /index.php?page=$1 [L,QSA]