Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.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 .htaccess子域目录_Php_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Php .htaccess子域目录

Php .htaccess子域目录,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,我的.htaccess代码是: RewriteRule ^404\.php$ - [L] Rewritecomnd %{HTTP_HOST} !^www\.example\.com Rewritecomnd %{HTTP_HOST} ([^.]+)\.example\.com [NC] RewriteRule ^/?$ /profile/index.php?name=%1 [L] Rewritecomnd %{HTTP_HOST} !^www\.example\.com Rewritecom

我的.htaccess代码是:

RewriteRule ^404\.php$ - [L]

Rewritecomnd %{HTTP_HOST} !^www\.example\.com
Rewritecomnd %{HTTP_HOST} ([^.]+)\.example\.com [NC]
RewriteRule ^/?$ /profile/index.php?name=%1 [L]

Rewritecomnd %{HTTP_HOST} !^www\.example\.com
Rewritecomnd %{HTTP_HOST} [^.]+\.example\.com [NC]
Rewritecomnd %{REQUEST_URI} ^/([^/]+)$
RewriteRule !^profile/ /profile/%1 [L]
让我告诉你这是怎么回事:

  • bob.example.com
    显示页面
    www.example.com/profile/index.php?name=bob
  • bob.example.com/page1.php
    仅显示来自profile目录
    www.example.com/profile/page1.php
  • 问题:

    问题是,如果我转到
    bob.example.com/directory/page.php
    ,它会显示根目录的目录。我怎样才能做到这一点
    bob.example.com/directory/page.php
    显示了
    www.example.com/profile/directory/page2.php

    您的RewriteCond模式与uri/directory/page.php不匹配。您需要从正则表达式中删除受限制的/,或者改用一种全面模式

    将上次重写更改为:

     RewriteCond %{REQUEST_URI} ^/(.+)$