Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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
Apache 在本地主机windows xampp上配置mod_rewrite_Apache_.htaccess_Mod Rewrite_Xampp - Fatal编程技术网

Apache 在本地主机windows xampp上配置mod_rewrite

Apache 在本地主机windows xampp上配置mod_rewrite,apache,.htaccess,mod-rewrite,xampp,Apache,.htaccess,Mod Rewrite,Xampp,我正在尝试让mod_rewrite在localhost上工作。如果我转到localhost/website,它将加载 DirectoryIndex home.php 及 也有效 但对于其他页面,它只显示主页 RewriteEngine On RewriteBase / RewriteRule ^home/?$ home.php [NC,L] RewriteRule ^about/?$ about.php [NC,L] <--- this goes t

我正在尝试让mod_rewrite在localhost上工作。如果我转到localhost/website,它将加载

DirectoryIndex home.php

也有效

但对于其他页面,它只显示主页

RewriteEngine On
RewriteBase /
RewriteRule    ^home/?$    home.php    [NC,L]
RewriteRule    ^about/?$    about.php    [NC,L]  <--- this goes to home
重新编写引擎打开
重写基/
重写规则^home/?$home.php[NC,L]

重写规则^about/?$about.php[NC,L]您在浏览器中输入的确切URL是什么?此.htaccess位于何处?localhost/website/about和htaccess位于C:/xampp/htdocs/website文件夹您需要使用此URL:
http://locahost/about
好的,可以了,因此,如果我想使用localhost/website/about,我是否需要将ServerName更改为localhost/website?为此,您需要更改
DocumentRoot
RewriteEngine On
RewriteBase /
RewriteRule    ^home/?$    home.php    [NC,L]
RewriteRule    ^about/?$    about.php    [NC,L]  <--- this goes to home
<VirtualHost *:80>

ServerName localhost

DocumentRoot "C:/xampp/htdocs/website"

<Directory "C:/xampp/htdocs/website">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>