首页 文章

如何在URL重写中跳过index.php?

提问于
浏览
1

好!我已经设置了运行并没有太多麻烦 . 但事情是我无法跳过我的网址中的index.php(localhost / index.php / login正在运行但localhost / login无法正常工作) . 无论如何,我的项目基于CI框架,我之前使用vagrant来托管同一个项目,并且这个案例非常适合 . 我已经检查了apache的rewrite_module,这里是我的.htaccess文件

DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]`enter code here`

请从这里帮助我 .

2 回答

  • 2

    首先进入你的项目myproject-application-> config.php

    replace line no. 29
    From
    $config['index_page'] = 'index.php';
    To
    $config['index_page'] = '';
    

    然后在根文件夹中添加.htaccess文件 .

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
    </IfModule>
    
  • 3

    试试这个.htaccess文件代码:

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

相关问题