Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/253.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
Php 子域请求默认为主域索引_Php_Apache_.htaccess_Mod Rewrite_Redirect - Fatal编程技术网

Php 子域请求默认为主域索引

Php 子域请求默认为主域索引,php,apache,.htaccess,mod-rewrite,redirect,Php,Apache,.htaccess,Mod Rewrite,Redirect,我的问题与这个问题有关,但这是一个老问题,没有公认的答案 我有一个托管的子域网站。一个子域工作正常,但它有一个.htaccess文件,可以将所有内容重定向到index.php 对于另一个子域,我不想这样做。它将链接到特定页面,但对于主页,如果我键入subdomain.domain.com/index,它将找到该页面,但如果我键入subdomain.domain.com,它将恢复到主域索引页面,即www.domain.com/index,而不是www.domain.com/subdomain/in

我的问题与这个问题有关,但这是一个老问题,没有公认的答案

我有一个托管的子域网站。一个子域工作正常,但它有一个.htaccess文件,可以将所有内容重定向到index.php

对于另一个子域,我不想这样做。它将链接到特定页面,但对于主页,如果我键入subdomain.domain.com/index,它将找到该页面,但如果我键入subdomain.domain.com,它将恢复到主域索引页面,即www.domain.com/index,而不是www.domain.com/subdomain/index

我在主域中有以下内容。htaccess,但条件应该阻止导致问题的重写,对吗?我也评论了所有这些,仍然得到问题

   RewriteCond %{HTTP_HOST} !^www\.domain\.com$     [NC]
   RewriteCond %{HTTP_HOST} !^sub1\.domain\.com$    [NC]
   RewriteCond %{HTTP_HOST} !^sub2\.domain\.com$ [NC]
   RewriteRule ^/(.*)$       http://www.domain.com/$1 [L,R=301]
我也有

DirectoryIndex index.php index.html
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L]
在主域.htaccess和子域.htaccess中指定


感觉这应该是直截了当的事情,有人能帮忙吗?

你的子域设置如何?您能显示它的VirtualHost条目吗?它是通过主机控制面板设置的,注册为sub2.domain.com,并在文件系统中引用www/sub2。这就是您的意思-我没有使用实际名称。我假设重定向发生在某个地方,如果我按找到的文件名引用这些文件-只有当保留为空时,它才会找到错误的索引文件。我也尝试过在.htaccess文件中放置一个特定的重定向,但即使这样也不起作用。