【问题标题】:CodeIgniter htaccess file after migrate to online host迁移到在线主机后的 CodeIgniter htaccess 文件
【发布时间】:2014-04-29 04:02:07
【问题描述】:

我在 localhost 上使用 CI 开发了一个网站, 在站点根目录中,我有以下 .htaccess 文件:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

#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.*
RewriteRule ^(.*)$ /xxxyyyzzz/index.php?/$1 [L]

#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /xxxyyyzzz/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 ^(.*)$ /xxxyyyzzz/index.php?/$1 [L]

<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

xxxyyyzzz 是我的网站名称,我在浏览器中打开它:(127.0.0.1/xxxyyyzzz/SomeControllerName/SomeMethodName)。

我将我的网站迁移到公共网络主机 (ip = aaa.bbb.ccc.ddd)
我应该如何更改 htaccess 文件? 我尝试了许多在网上找到的解决方案,但都没有奏效...
谢谢!

【问题讨论】:

  • 如果您的域没有指向 CI 根目录 RewriteBase / xxxyyyzzz 否则删除 CI 目录

标签: apache .htaccess codeigniter codeigniter-2


【解决方案1】:

正如tomexsans 评论的那样,您的重写规则是RewriteRule ^(.*)$ /xxxyyyzzz/index.php?/$1 [L],因此如果您不使用子目录/xxxyyyzzz,则需要将其删除。还要确保您正在更改 codeigniter application/config/config.php 文件中的默认路径。有时我在上传到现场网站时忘记更改某些内容,只需点你的 I 并交叉你的 T。 (:

/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
|   http://example.com/
|
| If this is not set then CodeIgniter will guess the protocol, domain and
| path to your installation.
|
*/
$config['base_url'] = '';

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-04
    • 2015-08-08
    • 2018-03-28
    • 1970-01-01
    • 2013-10-11
    • 2021-06-12
    相关资源
    最近更新 更多