【问题标题】:Codeigniter Xampp Remove index.phpCodeigniter Xampp 删除 index.php
【发布时间】:2017-04-04 02:33:39
【问题描述】:

我的本​​地服务器上有一个 sipmle php 应用程序。我正在使用 xampp。我正在尝试从我的网址中删除 index.php。我在互联网上查看了许多文章、文档和问题,并尝试了所有这些,但都没有奏效。这是我的 .htaccess 文件:

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

我已经在 config.php 上修改了这些行:

$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

并修改httpd.conf:

ServerName localhost:8080

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other 
# <Directory> blocks below.
#
<Directory />
    AllowOverride none
    Require all denied
</Directory>

...

DocumentRoot "C:/Projeler"
<Directory "C:/Projeler">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks Includes ExecCGI

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

先谢谢了。

【问题讨论】:

    标签: php codeigniter url-rewriting


    【解决方案1】:

    我在 windows xampp 下使用这个 htaccess

    project > .htaccess 确保文件在应用程序文件夹之外

    Options +FollowSymLinks
    Options -Indexes
    DirectoryIndex index.php
    RewriteEngine on
    RewriteCond $1 !^(index\.php|images|robots\.txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]
    

    然后

    $config['base_url'] = 'http://localhost/project/';
    
    $config['index_page'] = '';
    

    这里有更多 htaccess https://github.com/wolfgang1983/htaccess_for_codeigniter

    【讨论】:

      【解决方案2】:

      试试这个.htaccess

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-12-15
        • 2012-03-26
        • 1970-01-01
        • 2011-02-02
        • 2021-04-11
        • 2011-07-09
        • 1970-01-01
        • 2016-07-26
        相关资源
        最近更新 更多