簡體   English   中英

Apache重寫規則不起作用

[英]Apache rewrite rules not working

基本的重寫規則不起作用,我也不知道為什么。 這是我的hanalulu.conf

<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

</VirtualHost>

hosts文件中添加額外的一行並通過sudo a2ensite啟用站點sudo a2ensite 重新啟動Web服務器: hanalulu.localhost/a.html請求a.html而不是b.html

問題是什么?

我認為您需要路徑中的斜杠和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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM