簡體   English   中英

使用 htaccess 從 url 中刪除 index.php

[英]Removing index.php from url using htaccess

你好朋友,我正在嘗試從我的網站 URL 中刪除index.php ,我使用了.htaccess文件不起作用,我做錯了什么

RewriteEngine On

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

嘗試在.htaccess文件的頂部添加以下內容:

DirectoryIndex index.php

這指示 mod_dir 在請求目錄時發出index.php的內部子請求。 如果未正確設置或在請求的目錄中找不到index.php ,則您將收到 403 響應。

這通常已在大多數服務器上配置,但是,Apache 默認僅為index.html 如果這是默認設置,那么您在請求主頁時將收到 403。

您的“前端控制器”依賴於正確設置的DirectoryIndex

暫無
暫無

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

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