Apache重写规则不起作用

 myldd 发布于 2023-02-03 03:04

基本的重写规则不起作用,我不知道为什么.这是我的hanalulu.conf:



ServerName hanalulu.localhost
DocumentRoot /var/www/hanalulu/public
DirectoryIndex index.php


    AllowOverride all
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1


RewriteEngine on
RewriteRule ^a.html$ b.html


我在hosts文件中添加了一个额外的行并通过后启用了该站点sudo a2ensite.重新启动的Web服务器:hanalulu.localhost/a.html请求a.html而不是b.html.

问题是什么?

1 个回答
  • 我想你需要你的路径中的斜杠和RewriteRule上的标志,试试这个:

    <VirtualHost *:80>
    
    ServerName hanalulu.localhost
    DocumentRoot /var/www/hanalulu/public
    DirectoryIndex index.php
    
    <Directory />
        AllowOverride all
        Order Deny,Allow
        Deny from all
        Allow from 127.0.0.1
    </Directory>
    
    RewriteEngine on
    RewriteRule ^/a.html$ /b.html [R,L]
    
    </VirtualHost>
    

    2023-02-03 03:26 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有