问题描述:

I developed a website using CI on localhost,

at the site root directory I have the following .htaccess file:

<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

where xxxyyyzzz is my website name, and I open it in browser: (127.0.0.1/xxxyyyzzz/SomeControllerName/SomeMethodName).


I migrate my site to public web host (ip = aaa.bbb.ccc.ddd)

how should I change the htaccess file?

I tried many solutions that I found on the web but the did not work...

Thanks!


网友答案:

As tomexsans commented, your rewrite rules are RewriteRule ^(.*)$ /xxxyyyzzz/index.php?/$1 [L] so if you are not using the subdirectory /xxxyyyzzz than you need to remove it. Also make sure you are changing your default path in the codeigniter application/config/config.php file. Sometimes I forget to change certain things when I upload to the live site, just dot your I's and cross your T's. (:

/*
|--------------------------------------------------------------------------
| 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'] = '';
相关阅读:
Top