codeigniter删除index.php文件 - htaccess的本地主机 [英] Codeigniter remove index.php - htaccess localhost

查看:224
本文介绍了codeigniter删除index.php文件 - htaccess的本地主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经试过所有的解决方案,我发现这里的堆栈溢出,但没有成功。

我跑


  • 在XAMPP V3.2.1

  • 赢8.1和

  • codeigniter 3.0.4

使用的Smarty 3的最新版本所有这一切工作正常,只是直到我尝试从网址中删除'的index.php'的地步。

的config.php

  $配置['BASE_URL'] ='localhost'的;$配置['index_page'] ='';

routes.php文件

  $路线['default_controller'] ='家';$路线['接触'] ='接触';

的.htaccess

 < IfModule authz_core_module>
    要求所有被拒绝
< / IfModule>
<!IfModule authz_core_module>
    所有拒绝
< / IfModule>
< IfModule mod_rewrite.c>
  RewriteEngine叙述在
  #!重要!在这里设置您的RewriteBase,不要忘记尾随和领导
  #斜线。
  #如果你的网页在驻留
  #http://www.example.com/mypage/test1
  #然后使用
  #的RewriteBase /我的空间/测试1 /
  的RewriteBase / responsive_template /
  RewriteEngine叙述上
  的RewriteCond $ 1 ^(指数\\ .PHP |图片|机器人\\ .txt)的!
  重写规则^(。*)$ /index.php/$1 [L]
< / IfModule><!IfModule mod_rewrite.c>
  #如果我们没有mod_rewrite的安装,所有404的
  #可以发送到index.php,一切工作正常。
  ElliotHaughin:#提交  的ErrorDocument 404的index.php
< / IfModule>

阿帕奇的LoadModule rewrite_module模块/ mod_rewrite.so启用

 <目录/>    所有的AllowOverride    要求所有被拒绝< /目录>

如果我访问本地主机/ responsive_template / index.php文件/联系人一切工作正常,只有本地主机/ responsive_template /联系以404结束,仅此而已。

整个codeigniter应用程序文件夹中的子目录responsive_template项下 C:\\ XAMPP \\ htdocs中

感谢您的帮助球员,很多AP preciated。

BR
大卫


解决方案

我找到的 XAMPP WAMP 此htaccess的使用满。

 选项+的FollowSymLinks
选项​​-Indexes
的DirectoryIndex index.php文件
RewriteEngine叙述上
的RewriteCond $ 1 ^(指数\\ .PHP |图片|机器人\\ .txt)的!
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^(。*)$的index.php / $ 1 [L,QSA]

请您将主应用程序文件夹的htaccess文件的出方

设置你的基本URL像

一些事情

  $配置['BASE_URL'] ='的http://本地主机/项目/';
$配置['index_page'] ='';


  

注意::您可以将基本URL空白,但是当你提交有时一个形式,你会发现可能无法正常提交。因为它显示了
   ip_adress 的网址,而不是本地主机


目录

 应用程序系统的.htaccess的index.php


  

使用codeIgniter 3个版本,确保你也有类和文件
  名字的第一个字母大写。


文件名称例如:的welcome.php

 < PHP类扩展欢迎{是CI_Controller     公共功能指数(){     }
}

I've tried every solution I found here on stack overflow but no success.

I'm running

  • XAMPP v3.2.1 on
  • Win 8.1 and
  • Codeigniter 3.0.4

With the latest release of Smarty 3. All that is working fine just until the point I try to remove the 'index.php' from the URLs.

config.php

$config['base_url'] = 'localhost';

$config['index_page'] = '';

routes.php

$route['default_controller'] = 'home';

$route['contact'] = 'contact';

.htaccess

<IfModule authz_core_module>
    Require all denied
</IfModule>
<IfModule !authz_core_module>
    Deny from all
</IfModule>
<IfModule mod_rewrite.c>
  RewriteEngine On
  # !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
  #  slashes.
  # If your page resides at
  #  http://www.example.com/mypage/test1
  # then use
  # RewriteBase /mypage/test1/
  RewriteBase /responsive_template/
  RewriteEngine on
  RewriteCond $1 !^(index\.php|images|robots\.txt)
  RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
  # If we don't have mod_rewrite installed, all 404's
  # can be sent to index.php, and everything works as normal.
  # Submitted by: ElliotHaughin

  ErrorDocument 404 /index.php
</IfModule>

Apache ' LoadModule rewrite_module modules/mod_rewrite.so ' enabled

<Directory />

    AllowOverride all

    Require all denied

</Directory>

If I access localhost/responsive_template/index.php/contact all works fine, only the localhost/responsive_template/contact ends with a 404 and that's it.

The whole codeigniter application folder is in a subdirectory 'responsive_template' under c:\xampp\htdocs

Thanks for any help guys, much appreciated.

BR David

解决方案

I find with xampp and wamp this htaccess use full.

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]

Make you place the htaccess file out side of the main application folder.

Set your base url some thing like

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

Note: You can leave base url blank but some times when you submit a form you will find may not submit correctly. because it shows ip_adress in url instead of localhost

Directory

application

system

.htaccess

index.php

With codeIgniter 3 versions make sure also you have class and file names first letter upper case.

File name example: Welcome.php

<?php

class Welcome extends CI_Controller {

     public function index() {

     }
}

这篇关于codeigniter删除index.php文件 - htaccess的本地主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆