【问题标题】:removing index.php from site in php从 php 中的站点中删除 index.php
【发布时间】:2018-08-10 01:29:44
【问题描述】:

每当我尝试使用错误的用户详细信息登录我的网站时,我都会从www.example.com/ 重定向到www.example.com/index.php

我想从我的链接中删除index.php

这是我的htaccess 文件的内容,这对我不起作用。

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.php\ HTTP/
RewriteRule ^(.*)\.php$ /$1 [R=301,L]

RewriteRule ^login index.php [NC,L]

【问题讨论】:

  • 默认情况下它会重定向到站点 url。
  • 是的@GufranHasan
  • “错误的用户详细信息”是什么意思?
  • 每当我尝试使用错误的用户名和密码登录我的网站时,index.php 就会被添加到我的网址中,即www.example.com/index.php。我想摆脱index.php,这样用户甚至无法将其添加到我的网址中

标签: php .htaccess mod-rewrite url-rewriting


【解决方案1】:

检查这是否适合您:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

【讨论】:

  • 与第一个答案相同
【解决方案2】:

检查mod_rewrite 模块是否已启用,如果您没有先启用它。

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

Reference

htaccess documrntation

【讨论】:

猜你喜欢
  • 2012-11-14
  • 1970-01-01
  • 1970-01-01
  • 2010-10-28
  • 2018-03-30
  • 2012-07-19
  • 1970-01-01
  • 2015-09-06
  • 1970-01-01
相关资源
最近更新 更多