子域示例-lorem.example.com
里面唯一一页-index.php
和一个名为lang
的$_GET
参数lorem.example.com/en
-应解释为-lorem.example.com?lang=en
lorem.example.com/de
-应解释为-lorem.example.com?lang=de
这是我尝试,没有成功
RewriteEngine ON
RewriteRule ^(en)/?$ $1.php [QSA,NC,L]
RewriteRule ^(de)/?$ $1.php [QSA,NC,L]
2条答案
按热度按时间4jb9z9bj1#
您可以使用此规则:
在这里:
DirectoryIndex
对于在请求仅为http://lorem.example.com
时提供index.php
非常有用(如果Apache配置中未定义)(en|de)
匹配并捕获$1
中en
或de
,用作lang
参数中值omjgkv6w2#
请使用显示示例尝试以下.htaccess规则文件请确保在测试URL之前清除浏览器缓存
请确保将.htaccess和index.php文件保存在同一目录中。