
如何將 apache mod_rewrite 與 Alias 一起使用?我有一個包含以下文件的測試目錄: Correct.html index.html test_httpd.conf error.html 我想要一個使用別名的範例規則,該別名將任何對 error.html 的請求重定向到 Correct.html。另一個範例規則將對目錄 test 中的任何檔案的任何請求都指向 Correct.html 以下是我在 test_httpd.conf 中嘗試過的內容:
#DocumentRoot /var/www/localhost/htdocs/test
Alias /test /var/www/localhost/htdocs/test/
#<Directory /var/www/localhost/htdocs/test>
#<Directory /test>
<Directory test>
RewriteEngine On
#RewriteRule ^*$ rewriteme.html [R]
RewriteRule ^wrong.html$ correct.html [R]
</Directory>
我在 Gentoo 上使用 apache 2.4.6-r2。