htaccess:php 索引页上的语言变量
htaccess: php language variable on index page
我正在尝试从扩展中清理 url 并 php 获取语言变量:
test.com/en/ => test.com/?lang=zh
test.com/ro/page/ => test.com/page.php?lang=ro
这是我的 .htaccess:
AddDefaultCharset utf-8
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]
RewriteRule ^([^/]+)/([^.]+)\.php /.php?lang= [L,NC,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ .php
RewriteRule ^([^/]+)/([^/]+)/$ //.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ // [R=301,L]
同时转换test.com/ro/page => test.com/page.php?lang=ro
和 test.com/ro/index => test.com/index.php?lang=ro
我无法将其转换为索引页测试。com/en/ => test.com/?lang=zh
你们能帮我实现这个吗?
根据此规则:
RewriteRule ^([^/]+)/([^.]+)\.php /.php?lang= [L,NC,QSA]
尝试添加这条规则:
RewriteRule ^([^/]{2})/?$ /?lang= [L,NC,QSA]
我正在尝试从扩展中清理 url 并 php 获取语言变量:
test.com/en/ => test.com/?lang=zh
test.com/ro/page/ => test.com/page.php?lang=ro
这是我的 .htaccess:
AddDefaultCharset utf-8
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]
RewriteRule ^([^/]+)/([^.]+)\.php /.php?lang= [L,NC,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ .php
RewriteRule ^([^/]+)/([^/]+)/$ //.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ // [R=301,L]
同时转换test.com/ro/page => test.com/page.php?lang=ro 和 test.com/ro/index => test.com/index.php?lang=ro
我无法将其转换为索引页测试。com/en/ => test.com/?lang=zh
你们能帮我实现这个吗?
根据此规则:
RewriteRule ^([^/]+)/([^.]+)\.php /.php?lang= [L,NC,QSA]
尝试添加这条规则:
RewriteRule ^([^/]{2})/?$ /?lang= [L,NC,QSA]