[英]Removing index.php from url using htaccess
Hello friends I am trying to remove index.php
from my website URL, it is not working to do that I have used .htaccess
file, Is there something i am doing wrong你好朋友,我正在尝试从我的网站 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]
Try adding the following at the top of your .htaccess
file:尝试在
.htaccess
文件的顶部添加以下内容:
DirectoryIndex index.php
This instructs mod_dir to issue an internal subrequest for index.php
when requesting a directory.这指示 mod_dir 在请求目录时发出
index.php
的内部子请求。 If this is not set appropriately or index.php
is not found in the requested directory then you'll get a 403 response.如果未正确设置或在请求的目录中找不到
index.php
,则您将收到 403 响应。
This is often already configured on most servers, however, the Apache default is index.html
only.这通常已在大多数服务器上配置,但是,Apache 默认仅为
index.html
。 If this is left as default then you'll get a 403 when requesting the homepage.如果这是默认设置,那么您在请求主页时将收到 403。
Your "front-controller" is relying on the DirectoryIndex
being set correctly.您的“前端控制器”依赖于正确设置的
DirectoryIndex
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.