codeigniter安装子目录 [英] Codeigniter installation in subdirectory

查看:137
本文介绍了codeigniter安装子目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要安装的codeigniter最新版本的子目录。该工程至今。但现在我想从URL中删除的index.php 。所以因此我在子文件夹中该的.htaccess 文件。

  RewriteEngine叙述上
的RewriteBase的/ dev /

#删除结尾的斜杠(prevents SEO重复内容的问题)
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^(+)/ $ $ 1 [L,R = 301]

###

#删除用户访问系统文件夹中。
#此外,这将允许您创建一个System.php控制器,
#previously这将是不可能。
#'系统'可以,如果你已重命名系统文件夹进行更换。
的RewriteCond%{REQUEST_URI} ^系统。*
的RewriteCond%{REQUEST_URI} ^应用。*
重写规则^(。*)$ /index.php/$1 [L]

#检查是否该用户正在试图访问一个有效的文件,
#如图像或CSS文档,如果这是不正确的发送的
#请求的index.php
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^(。*)$ /index.php/$1 [L]
 

子文件夹的名称是开发和根目录(父文件夹)是空的。只是有一个 index.html的文件中了。

因此​​,这是造成这种结构:

  /无功/网络/
    的index.html
    开发/
        这里词安装
        的.htaccess
 

当然mod-rewrite已启用。

任何想法,为什么它不会工作? //domain.tld/dev/login HTTP时,我得到一个404错误>

解决方案

您需要两样东西。

的config.php ,配置 index_page 是空的,所以网址正确创建

  $配置['index_page'] ='';
 

和您的的.htaccess

  RewriteEngine叙述上
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^ * $的index.php / $ 0个
 

系统的接入应用程序已明令禁止的.htaccess目录在这些子目录中的文件,用codeigniter交付。

I want to install the latest version of codeigniter in a subdirectory. That works so far. But now I want to remove the index.php from the url. So therefore I have this .htaccess file in the subfolder.

RewriteEngine On
RewriteBase /dev/

# Removes trailing slashes (prevents SEO duplicate content issues)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]

###

# Removes access to the system folder by users.
# Additionally this will allow you to create a System.php controller,
# previously this would not have been possible.
# 'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php/$1 [L]

# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

The name of the subfolder is dev and the webroot (the parent folder) is empty. There is just an index.html file in it.

So this is resulting in this structure:

/var/www/
    index.html
    dev/
        ci installation here
        .htaccess

and of course mod-rewrite is enabled.

Any ideas why it wont work? I get an 404 Error when calling something like http://domain.tld/dev/login

解决方案

You need two things.

In the config.php, configure index_page to be empty, so the URLs are created properly

$config['index_page'] = '';

and in your .htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php/$0

The access to the system and application directories is already prohibited by the .htaccess files in these subdirectories, delivered by Codeigniter.

这篇关于codeigniter安装子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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