简体   繁体   中英

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

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:

DirectoryIndex index.php

This instructs mod_dir to issue an internal subrequest for index.php when requesting a directory. If this is not set appropriately or index.php is not found in the requested directory then you'll get a 403 response.

This is often already configured on most servers, however, the Apache default is index.html only. If this is left as default then you'll get a 403 when requesting the homepage.

Your "front-controller" is relying on the DirectoryIndex being set correctly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM