簡體   English   中英

mod_rewrite 不起作用

[英]mod_rewrite is not working

我在 windows 上使用 xampp。最近兩天我試圖重寫 URL,但 mod rewrite 什么也沒做。它把我帶到同一個頁面。我試圖做一個簡單的從 foo.html 重定向到 bar.html 作為它的是重寫文檔的示例。 我已將所有指令放在 .htaccess 中。

.htaccess 正在處理導致在其中添加類似“blah blah blah”的內容導致500 internal server error 這是我的 .htaccess 文件中的幾行。

RewriteEngine On
RewriteRule ^/foo.html /bar.html [R]

我啟用了日志記錄,這是我在 trace3 上對 foo.html 的最后一次請求告訴我的信息。

[Sat Jun 14 12:00:49.125000 2014] [rewrite:trace3] [pid 5116:tid 8]    mod_rewrite.c(475): [client 127.0.0.1:4656] 127.0.0.1 - - [localhost/sid#9006d0][rid#9dd270/initial] [perdir D:/x3/htdocs/] strip per-dir prefix: D:/x3/htdocs/foo.html -> foo.html

[Sat Jun 14 12:00:49.125000 2014] [rewrite:trace3] [pid 5116:tid 8] mod_rewrite.c(475): [client 127.0.0.1:4656] 127.0.0.1 - - [localhost/sid#9006d0][rid#9dd270/initial] [perdir D:/x3/htdocs/] applying pattern '^/foo.html' to uri 'foo.html'

[Sat Jun 14 12:00:49.125000 2014] [rewrite:trace1] [pid 5116:tid 8] mod_rewrite.c(475): [client 127.0.0.1:4656] 127.0.0.1 - - [localhost/sid#9006d0][rid#9dd270/initial] [perdir D:/x3/htdocs/] pass through D:/x3/htdocs/foo.html

[Sat Jun 14 12:00:49.531250 2014] [rewrite:trace3] [pid 5116:tid 8] mod_rewrite.c(475): [client 127.0.0.1:4656] 127.0.0.1 - - [localhost/sid#9006d0][rid#55020a8/initial] [perdir D:/x3/htdocs/] strip per-dir prefix: D:/x3/htdocs/favicon.ico -> favicon.ico

[Sat Jun 14 12:00:49.531250 2014] [rewrite:trace3] [pid 5116:tid 8] mod_rewrite.c(475): [client 127.0.0.1:4656] 127.0.0.1 - - [localhost/sid#9006d0][rid#55020a8/initial] [perdir D:/x3/htdocs/] applying pattern '^/foo.html' to uri 'favicon.ico'

[Sat Jun 14 12:00:49.531250 2014] [rewrite:trace1] [pid 5116:tid 8] mod_rewrite.c(475): [client 127.0.0.1:4656] 127.0.0.1 - - [localhost/sid#9006d0][rid#55020a8/initial] [perdir D:/x3/htdocs/] pass through D:/x3/htdocs/favicon.ico

我不知道出了什么問題?:(

請幫幫我。 我過去曾成功使用過 mod_rewrite,但不知道我做錯了什么。

我想到了。 我改變了我的 .htaccess 中的行

RewriteEngine On

RewriteRule ^/foo.html /bar.html [R]

RewriteEngine on

RewriteRule ^foo\.html /bar.html [R]

現在它工作正常。

我猜這是因為 '/' 自動添加到 .htaccess 中,並且我還包含了一個尾部斜杠,因此 RewriteRule 沒有找到匹配項,因此它沒有做任何事情。

但事實並非如此或 httpd.conf。 此外, rewriteBase 在這里在某種程度上很重要。

暫無
暫無

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

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