簡體   English   中英

htaccess - 即使在 localhost 上的 httpd.conf 中啟用 htaccess 文件,也會顯示 500 錯誤

[英]htaccess - displaying 500 Error even enabling the htaccess file in httpd.conf on localhost

.htaccess 顯示 500 服務器錯誤。
文件的位置是根文件夾。 下面是代碼:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule .signup.php [L]
RewriteRule .* .signup.php [PT,L]
</IfModule>

我在 httpd.conf 文件中啟用了 htaccess 文件

<Directory />
  Options FollowSymLinks
  AllowOverride all
  Order deny,allow
  Deny from all
  Satisfy all
</Directory>

LoadModule rewrite_module modules/mod_rewrite.so

您的RewriteBase行在沒有指定目錄的情況下有問題。
嘗試: RewriteBase / - RewriteBase / - 完全刪除該行。
如果這不起作用,我認為像這樣編寫 .htaccess 文件會更安全:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase / 

#If we're already on .signup.php, exit so we don't get stuck in a loop
    RewriteRule .signup.php - [L]

#If doesn't exist
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
#rewrite to .signup.php and read from the top of .htaccess again
    RewriteRule .* .signup.php [PT,L]
</IfModule>

這樣我們就可以避免重定向循環,以防萬一 .signup.php 文件也不存在..
如果這仍然不起作用,請嘗試在沒有 PT 標志的情況下進行測試,如果您不確定自己知道自己在做什么,它可能會使 .htaccess 復雜化。

暫無
暫無

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

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