我创建了一个 .htacces 文件,它执行以下操作:
重定向
/到/.index/(在地址栏中可见)或者
重定向
/hu或/en到/.index/hu或/.index/en(在地址栏中可见)
然后
- 将请求重定向
/.[p]/[l]到/index.php?page=[p]&lang=[l](在地址栏中不可见)
但..
我想在最后保留查询字符串,这意味着访问/.[p]/[l]?a=b结果会导致请求/index.php?page=[p]&lang=[l]&a=b
我似乎无法让正则表达式为此工作。这是整个 .htaccess 文件:
RewriteEngine On
RewriteBase /Main/djdavid98/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(hu|en)?(\/?(\?(([\S]+\=[\S]+)*))?)?$ ./.index/$1$3 [R=301,L]
RewriteRule ^\.([\w\d]+)(\/(hu|en))?\/?(\?(([\S]*=[\S]*)+))?$ index.php?page=$1&lang=$3&$5