首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >迁移到在线主机后的CodeIgniter htaccess文件

迁移到在线主机后的CodeIgniter htaccess文件
EN

Stack Overflow用户
提问于 2014-04-13 19:36:01
回答 1查看 458关注 0票数 0

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

代码语言:javascript
复制
<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]

代码语言:javascript
复制
<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).

我将我的站点迁移到公共web主机(ip = aaa.bbb.ccc.ddd)

如何更改htaccess文件?我尝试了许多我在网上找到的解决方案,但都不起作用……

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2014-04-29 04:02:08

正如tomexsans所评论的,您的重写规则是RewriteRule ^(.*)$ /xxxyyyzzz/index.php?/$1 [L],所以如果您不使用子目录/xxxyyyzzz,那么您需要删除它。还要确保您正在更改codeigniter application/config/config.php文件中的默认路径。有时当我上传到现场时,我会忘记更改某些内容,只需在I和T之间打点。(:

代码语言:javascript
复制
/*
|--------------------------------------------------------------------------
| 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'] = '';
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23042248

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档