Php wamp本地子域和htaccess重写规则

Php wamp本地子域和htaccess重写规则,php,.htaccess,mod-rewrite,wamp,mod-vhost-alias,Php,.htaccess,Mod Rewrite,Wamp,Mod Vhost Alias,最近,我用一点php mvc魔术修复了我的网站,我在.htaccess中使用了这些设置: Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^([a-zA-Z0-9]*)/?([a-zA-Z0-9]*)?/?([a-zA-Z0-

最近,我用一点php mvc魔术修复了我的网站,我在.htaccess中使用了这些设置:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([a-zA-Z0-9]*)/?([a-zA-Z0-9]*)?/?([a-zA-Z0-9]*)?/?$ index.php?controller=$1&action=$2&arg=$3 [NC,L]
它就像一个符咒。我遇到的唯一问题是,当我相对地引用css或图像等文件时,浏览器认为由于url中的虚线,我们向下移动了文件夹结构 localhost/projectname/controllername/action/id

因此css/styles.css是在localhost/controllername/action/id/css/styles.css请求的 拥有绝对路径解决了这个问题,但在没有“projectname”文件夹的情况下,拥有localtest服务器和远程实时和开发服务器并不能很好地解决这个问题

我决定配置我的本地wamp服务器,以便可以将不同的项目作为子域访问到我的本地主机,如“”

我激活了相关的apache模块,编辑了主机文件,并将httpd-vhosts.conf更改为

NameVirtualHost *:80
<VirtualHost *:80>
    ServerName localhost.com
    ServerAlias www.localhost.com
    DocumentRoot "C:\wamp\www"
    ErrorLog "logs\errors.log"
    <directory "C:\wamp\www">
        Options Indexes FollowSymLinks
        AllowOverride all
        Order Deny,Allow
        Deny from all
        Allow from all
    </directory>
</VirtualHost>

<VirtualHost *:80>
    ServerName localhost.com
    ServerAlias *.localhost.com
    VirtualDocumentRoot "C:\wamp\www\subdomains\%1"
    ErrorLog "logs\errors.log"
    <directory "C:\wamp\www\subdomains\%1">
        Options Indexes FollowSymLinks
        AllowOverride all
        Order Deny,Allow
        Deny from all
        Allow from all
    </directory>
</VirtualHost>
NameVirtualHost*:80
ServerName localhost.com
ServerAlias www.localhost.com
DocumentRoot“C:\wamp\www”
ErrorLog“logs\errors.log”
选项索引跟随符号链接
允许超越所有
命令拒绝,允许
全盘否定
通融
ServerName localhost.com
ServerAlias*.localhost.com
VirtualDocumentRoot“C:\wamp\www\subdomains\%1”
ErrorLog“logs\errors.log”
选项索引跟随符号链接
允许超越所有
命令拒绝,允许
全盘否定
通融
现在,当我调用projectname.localhost.com/controllername/action/id时,它告诉我 在此服务器上找不到请求的URL/subdomains/projectname/index.php。 而projectname.localhost.com/index.php仍然为我提供了正确的文件

我听说$_服务器['DOCUMENT_ROOT']可能有问题;。这并没有得到正确的设置,但知道这并没有帮助我解决这个问题


有人能给我指出正确的方向或建议另一种环境配置,使在这些情况下进行测试成为可能吗?

将我的.htaccess更改为

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([a-zA-Z0-9]*)/?([a-zA-Z0-9]*)?/?([a-zA-Z0-9]*)?/?$ index.php?controller=$1&action=$2&arg=$3 [NC,L]
解决了这个问题。 魔线是
RewriteBase/

似乎服务器真的在错误的位置查找index.php

希望这能帮助其他有同样问题的人…:)