【问题标题】:Url rewriting not working in WAMP Subdomain网址重写在 WAMP 子域中不起作用
【发布时间】:2016-09-29 04:10:13
【问题描述】:

我在我的 WAMP 服务器下为移动站点创建了一个子域,它使用 IP 地址作为域名,即192.168.106.1

但问题是,当我尝试在我的 .htaccess 文件中重写一个 url 时,我不起作用。我使用了一个重复的.htaccess 文件,它适用于localhost

下面是我httpd.conf文件中域名的服务器配置

<VirtualHost 192.168.106.1>
#LoadModule rewrite_module modules/mod_rewrite.so
# The name to respond to
ServerName m.localhost
# Folder where the files live
DocumentRoot "C:/wamp/www/mobile/"
# A few helpful settings...
<Directory "C:/wamp/www/mobile/">
Allow from all
Order Allow,Deny
# Enables .htaccess files for this site
AllowOverride All
</Directory>
# Apache will look for these two files, in this order, if no file is specified in the URL
DirectoryIndex index.html index.php
</VirtualHost> 

我还删除了第二行的注释标签,但它仍然不起作用。

请有解决方案的人?

【问题讨论】:

    标签: .htaccess url-rewriting wamp subdomain


    【解决方案1】:

    这是一个解决方案

    首先确保您转到您的C:/wamp/bin/apache/YOUR APACHE VERSION/conf 并打开您的httpd.conf 文件并取消注释此行

    #Include conf/extra/httpd-vhosts.conf
    

    所以它看起来像这样

    Include conf/extra/httpd-vhosts.conf
    

    然后打开位于C:/windows/System32/drivers/etc 中的host 文件并将其添加(您的IP 地址到配置中)

    #add the sub-domain name, in this case I use mobile, it can be anything
    192.168.106.1   mobile.localhost
    192.168.106.1   192.168.106.1
    

    最后也是最重要的,在C:/wamp/bin/apache/YOUR APACHE VERSION/conf/extra/httpd-vhosts.conf 中打开您的vhost 文件并将其添加到文件中

    <VirtualHost *:80>
        DocumentRoot "C:/wamp/www/mobile"
        ServerName m.localhost
        Options Indexes FollowSymLinks
        <Directory "C:/wamp/www/mobile">
            AllowOverride All
            Order Deny,Allow
            Deny from all
            Allow from 127.0.0.1
            #If you want to allow access from your internal network
            # For specific ip addresses add one line per ip address
            Allow from 192.168.106.1
            # For every ip in the subnet, just use the first 3 numbers of the subnet
            #Allow from 192.168.0
        </Directory>
    </VirtualHost>
    

    然后重新启动你的 WAMP 服务器,它就可以工作了

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-10
      • 2014-02-17
      • 2013-09-22
      • 2015-09-10
      • 1970-01-01
      • 2013-09-16
      • 2014-09-10
      相关资源
      最近更新 更多