【发布时间】:2022-01-30 06:28:22
【问题描述】:
这是否可能指向特定变量的子域?
http://whatever.example.com 指向http://example.com/file.php?var=1
http://whatever1.example.com 指向http://example.com/file.php?var=2
尝试了下面推荐的答案 - 代码有效但没有 css 样式:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(?:www\.)?whatever\.example\.com$
RewriteRule ^ /file.php?var=1 [L,QSA]
RewriteCond %{HTTP_HOST} ^(?:www\.)?whatever1\.example\.com$
RewriteRule ^ /file.php?var=2 [L,QSA]
或
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteCond %{HTTP_HOST} ^(?:www\.)?([^.]+)\.example\.com$
RewriteRule ^ /file.php?var=%1 [L,QSA]
通过添加 <base href=""/>in 标头并为我的 css 创建一个名为 cssfolder 的文件夹来使其正常工作,因为根文件夹无法正常工作。不知道为什么?
<base href="../" /> "not working"
<base href="/" /> "not working"
<base href="./" /> "not working"
<base href="/cssfolder/" /> "this work"
【问题讨论】:
标签: .htaccess variables url-rewriting