mod_rewrite 不适用于 Windows 7 上的 Apache 2.2 [英] mod_rewrite not working for Apache 2.2 on Windows 7

查看:17
本文介绍了mod_rewrite 不适用于 Windows 7 上的 Apache 2.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 Windows 7 机器上启动并运行了 WampServer.它安装在 C:/wamp 中.我已经在 C:/wamp/bin/apache/Apache2.2.1.7/conf/extras/httpd-vhosts

I have WampServer up and running on my Windows 7 machine. It is installed in C:/wamp. I have set up my configuration using the following VirtualHosts in the C:/wamp/bin/apache/Apache2.2.1.7/conf/extras/httpd-vhosts

NameVirtualHost *:80

<VirtualHost *:80>
                ServerName localhost
                ServerAlias localhost
                DocumentRoot "C:/wamp/www"
                <Directory "C:/wamp/www">
                                Options Indexes Includes FollowSymLinks ExecCGI MultiViews
                                AllowOverride all
                                Order Allow,Deny
                                Allow from all
                </Directory>
</VirtualHost>


<VirtualHost *:80>
                DocumentRoot "C:/wamp/www/DevelopmentServer/clickslide/webroot"
                ServerName clickslide.loc
                <Directory "C:/wamp/www/DevelopmentServer/clickslide/webroot">
                                Options Indexes Includes FollowSymLinks ExecCGI MultiViews
                                AllowOverride all
                                Order Allow,Deny
                                Allow from all
                </Directory>
                DirectoryIndex     index.html index.php
    AccessFileName     .htaccess
                AddType application/x-httpd-php .php
    AddType application/x-httpd-php .php3
</VirtualHost>

我的服务器可以正常启动和停止,并且可以很好地提供 HTML 文件和 PHP 文件,但它忽略了我的 .htaccess 指令.我在 Macintosh 上设置了 MAMP 和 Apache,htaccess 工作正常.话虽如此,我想我在 Windows 上遗漏了一些明显的东西.

My server starts and stops fine, and serves HTML files and PHP files just fine but it ignores my .htaccess directives. I have MAMP with Apache set up on my Macintosh and the htaccess works fine. With that said I think I’m missing something obvious on Windows.

这里是我的htaccess的内容

Here are the contents of my htaccess

RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

我什至尝试向那些不会导致服务器错误的垃圾中添加一些垃圾,所以我知道没有读取 htaccess.

I have even tried adding some Garbage to that which does not cause a server error so I know the htaccess is not being read.

这是我的配置文件

ServerRoot "c:/wamp/bin/apache/apache2.2.17"


Listen 80


LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
#LoadModule auth_digest_module modules/mod_auth_digest.so
#LoadModule authn_alias_module modules/mod_authn_alias.so
#LoadModule authn_anon_module modules/mod_authn_anon.so
#LoadModule authn_dbd_module modules/mod_authn_dbd.so
#LoadModule authn_dbm_module modules/mod_authn_dbm.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authn_file_module modules/mod_authn_file.so
#LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
#LoadModule authz_dbm_module modules/mod_authz_dbm.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
#LoadModule authz_owner_module modules/mod_authz_owner.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
#LoadModule cache_module modules/mod_cache.so
#LoadModule cern_meta_module modules/mod_cern_meta.so
LoadModule cgi_module modules/mod_cgi.so
#LoadModule charset_lite_module modules/mod_charset_lite.so
#LoadModule dav_module modules/mod_dav.so
#LoadModule dav_fs_module modules/mod_dav_fs.so
#LoadModule dav_lock_module modules/mod_dav_lock.so
#LoadModule dbd_module modules/mod_dbd.so
#LoadModule deflate_module modules/mod_deflate.so
LoadModule dir_module modules/mod_dir.so
#LoadModule disk_cache_module modules/mod_disk_cache.so
#LoadModule dumpio_module modules/mod_dumpio.so
LoadModule env_module modules/mod_env.so
#LoadModule expires_module modules/mod_expires.so
#LoadModule ext_filter_module modules/mod_ext_filter.so
#LoadModule file_cache_module modules/mod_file_cache.so
#LoadModule filter_module modules/mod_filter.so
#LoadModule headers_module modules/mod_headers.so
#LoadModule ident_module modules/mod_ident.so
#LoadModule imagemap_module modules/mod_imagemap.so
LoadModule include_module modules/mod_include.so
#LoadModule info_module modules/mod_info.so
LoadModule isapi_module modules/mod_isapi.so
#LoadModule ldap_module modules/mod_ldap.so
#LoadModule logio_module modules/mod_logio.so
LoadModule log_config_module modules/mod_log_config.so
#LoadModule log_forensic_module modules/mod_log_forensic.so
#LoadModule mem_cache_module modules/mod_mem_cache.so
LoadModule mime_module modules/mod_mime.so
#LoadModule mime_magic_module modules/mod_mime_magic.so
LoadModule negotiation_module modules/mod_negotiation.so
#LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
#LoadModule proxy_connect_module modules/mod_proxy_connect.so
#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
#LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
#LoadModule speling_module modules/mod_speling.so
#LoadModule ssl_module modules/mod_ssl.so
#LoadModule status_module modules/mod_status.so
#LoadModule substitute_module modules/mod_substitute.so
#LoadModule unique_id_module modules/mod_unique_id.so
#LoadModule userdir_module modules/mod_userdir.so
#LoadModule usertrack_module modules/mod_usertrack.so
#LoadModule version_module modules/mod_version.so
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule php5_module "c:/wamp/bin/php/php5.3.5/php5apache2_2.dll"

<IfModule !mpm_netware_module>
<IfModule !mpm_winnt_module>
User daemon
Group daemon

</IfModule>
</IfModule>


ServerAdmin admin@localhost

ServerName localhost:80

DocumentRoot "c:/wamp/www/"

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

<Directory "c:/wamp/www/">
    Options Indexes FollowSymLinks
    AllowOverride all
#   onlineoffline tag - don't remove
    Order Allow,Deny
    Allow from all
</Directory>

<IfModule dir_module>
    DirectoryIndex index.php index.php3 index.html index.htm
</IfModule>

<FilesMatch "^.ht">
    Order allow,deny
    Deny from all
    Satisfy All
</FilesMatch>

ErrorLog "c:/wamp/logs/apache_error.log"

LogLevel warn

<IfModule log_config_module>
    LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined
    LogFormat "%h %l %u %t "%r" %>s %b" common

    <IfModule logio_module>
      LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i" %I %O" combinedio
    </IfModule>

    CustomLog "c:/wamp/logs/access.log" common
</IfModule>

<IfModule alias_module>
    ScriptAlias /cgi-bin/ "cgi-bin/"
</IfModule>


<Directory "cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

DefaultType text/plain

<IfModule mime_module>
    TypesConfig conf/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php .php3
</IfModule>


Include conf/extra/httpd-autoindex.conf
Include conf/extra/httpd-vhosts.conf
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>

Include "c:/wamp/alias/*"

推荐答案

在 apache config 上,将 DocumentRoot 定义上的AllowOverride"更改为All"即可解决问题

on apache config, changing "AllowOverride" to "All" on the definition of the DocumentRoot will solve the issue

这篇关于mod_rewrite 不适用于 Windows 7 上的 Apache 2.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆