Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess point子域到文件_.htaccess - Fatal编程技术网

.htaccess point子域到文件

.htaccess point子域到文件,.htaccess,.htaccess,我试图做的是能够将类似于username.domain.com的内容指向index.php?url=username。我一直在浏览Google/StackOveflow,没有找到任何对我有利的东西 致以最诚挚的问候。将以下规则添加到文档根目录中的htaccess文件中: RewriteEngine On RewriteCond %{HTTP_HOST} !^(www\.)?domain.com$ [NC] RewriteCond %{HTTP_HOST} ^([^.]+)\.domain.com

我试图做的是能够将类似于
username.domain.com
的内容指向
index.php?url=username
。我一直在浏览Google/StackOveflow,没有找到任何对我有利的东西


致以最诚挚的问候。

将以下规则添加到文档根目录中的htaccess文件中:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.)?domain.com$ [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain.com$ [NC]
RewriteCond %{REQUEST_URI} !index.php
RewriteRule ^ /index.php?url=%1 [L]

第一个条件确保请求的主机不是www.domain.comdomain.com,下一行匹配并分组子域名,规则本身使用查询字符串url和子域(使用%1反向引用)将所有内容重写为
/index.php

不起作用。我正在
RewriteCond%{HTTP_HOST}上使用
RewriteEngine^(www\.)?titancontent.com$[NC]
RewriteCond%{HTTP\u HOST}^([^.]+)\.titancontent.com$[NC]
RewriteRule^/index.php?url=%1[L]
并且它说GC找不到该页面。@BryanParmenter缺少一个条件来排除对
index.php
@BryanParmenter的请求,您试图转到哪个url?-我在index.php文件中设置了一个请求,以查看它是否通过php$\u GET命中aviance,但该页面返回时好像它不存在。@BryanParmenter,如果您转到它,它是否工作?另外,当我试图查找aviance.titancontent.com时,它说没有该主机名的DNS条目。