【发布时间】:2016-05-11 20:16:54
【问题描述】:
绑定 DNS 设置:
*.se7en.net.pl A Default 12.34.56.789
Apache 虚拟主机:
DocumentRoot /var/www/wild
ServerAlias *.se7en.net.pl
<Directory "/var/www/wild">
allow from all
Options None
Require all granted
</Directory>
这适用于每当我键入任何子域时重定向到/var/www/wild 目录。
但是,当我在 /var/www/wild 中创建 .htaccess 文件时,它得到了:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^se7en\.net\.pl [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.([^\.]+)\.([^\.]+)$
RewriteRule ^(.*)$ http://se7en.net.pl/hta.php?id=$1 [L,R=301,NC]
收到错误 403 禁止访问...
我想达到那个效果:
如果我去tits.se7en.net.pl,我希望这个页面被称为:http://se7en.net.pl/hta.php?id=tits,但我不知道该怎么做;(
一旦我使用了这个代码,它就开始工作了:RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.+?)\.se7en\.net\.pl$
RewriteRule .* http://test.se7en.net.pl/hta.php?id=%1 [L]
但是,每当我进入 tits.se7en.net.pl 时,地址栏就会变为 http://test.se7en.net.pl/hta.php?id=tits,这是我想隐藏的。
这可以隐藏吗?
【问题讨论】:
-
这里是
.htaccess规则 github.com/phanan/htaccess 的绝佳资源 -
是的,它确实是很好的资源,但也许我很愚蠢,但我没有看到任何适合我当前需求的东西。
-
我已经更新了我的答案来做到这一点
标签: php apache .htaccess mod-rewrite dns