【问题标题】:htaccess remove index.php and index.php/htaccess 删除 index.php 和 index.php/
【发布时间】:2019-06-17 19:32:06
【问题描述】:

我用谷歌搜索了很多,但我找不到从这两种情况中删除 index.php 的任何规则:

  1. domain.com/index.php => domain.com
  2. domain.com/index.php/other/stuff => domain.com/other/stuff

这是我到目前为止所做的

RewriteRule .* index.php [L]
RewriteCond %{REQUEST_URI}  !(administrator) [NC] #exclude administrator folder
#RewriteRule ^index.php$ /$1 [R=301] #when this is enable work only first case
RewriteRule ^(.*)index.php$ /$1 [R=301,L] #when this is enable work only second case

如果我启用这两种情况,所有请求都会重定向到 domain.com

谢谢。

【问题讨论】:

    标签: apache .htaccess joomla


    【解决方案1】:

    首先确保 MOD 重写已开启。

    试试这个代码

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

    希望这行得通!

    【讨论】:

    • PHP 5.3.28 (cgi-fcgi) (build: Oct 25 2014 13:49:56) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998 -2013 Zend Technologies 使用 ionCube PHP Loader + Intrusion Protection from ioncube24.com v5.0.6, Copyright (c) 2002-2015, by ionCube Ltd.
    • 试试这个.. RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^(.+ )$ index.php/$1 [L]
    • 您是否将 htaccess.txt 文件重命名为 .htaccess?
    【解决方案2】:

    希望这行得通!

    RewriteEngine on
    RewriteCond $1 !^(index\.php|resources|assets|robots\
    .txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-08-15
      • 2019-04-06
      • 2016-05-13
      • 2016-03-15
      • 2013-09-15
      • 2011-05-20
      • 2015-03-09
      • 2017-03-15
      相关资源
      最近更新 更多