2013-12-11 78 views
1

我已經創建了一個使用Codeigniter的應用程序,並且我將它託管到一個子域中,我還使用了一個htaccess文件來重定向,並將htaccess文件放在與系統和應用程序相同的文件夾中文件夾,但我無法訪問該網站,我相信我做錯了什麼,但我不知道它是什麼。當我訪問的網站,它說找不到網頁Codeigniter網址不能與子域一起工作

我的配置

$config['base_url'] = 'http://www.favouritememories.abovetheblues.co.uk/'; 

htaccess的我的配置的

<IfModule mod_rewrite.c> 

    RewriteEngine On 
    RewriteBase/

    ### Canonicalize codeigniter URLs 

    # If your default controller is something other than 
    # "welcome" you should probably change this 
    RewriteRule ^(favoriteMemories(/index)?|index(\.php)?)/?$/[L,R=301] 
    RewriteRule ^(.*)/index/?$ $1 [L,R=301] 

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

    # Enforce www 
    # If you have subdomains, you can add them to 
    # the list using the "|" (OR) regex operator 
    RewriteCond %{HTTP_HOST} !^(www|favouritememories.abovetheblues) [NC] 
    RewriteRule ^(.*)$ http://www.abovetheblues.co.uk/$1 [L,R=301] 

    # Enforce NO www 
    #RewriteCond %{HTTP_HOST} ^www [NC] 
    #RewriteRule ^(.*)$ http://domain.tld/$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.* 
    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] 

</IfModule> 

<IfModule !mod_rewrite.c> 

    # Without mod_rewrite, route 404's to the front controller 
    ErrorDocument 404 /index.php 

</IfModule> 

第幾行

<?php if (! defined('BASEPATH')) exit('No direct script access allowed'); 

/* 
|-------------------------------------------------------------------------- 
| 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'] = 'http://favouritememories.abovetheblues.co.uk/'; 

/* 
|-------------------------------------------------------------------------- 
| Index File 
|-------------------------------------------------------------------------- 
| 
| Typically this will be your index.php file, unless you've renamed it to 
| something else. If you are using mod_rewrite to remove the page set this 
| variable so that it is blank. 
| 
*/ 
$config['index_page'] = ''; 

/* 
|-------------------------------------------------------------------------- 
| URI PROTOCOL 
|-------------------------------------------------------------------------- 
| 
| This item determines which server global should be used to retrieve the 
| URI string. The default setting of 'AUTO' works for most servers. 
| If your links do not seem to work, try one of the other delicious flavors: 
| 
| 'AUTO'   Default - auto detects 
| 'PATH_INFO'  Uses the PATH_INFO 
| 'QUERY_STRING' Uses the QUERY_STRING 
| 'REQUEST_URI'  Uses the REQUEST_URI 
| 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO 
| 
*/ 
$config['uri_protocol'] = 'AUTO'; 

/* 
|-------------------------------------------------------------------------- 
| URL suffix 
|-------------------------------------------------------------------------- 
| 
| This option allows you to add a suffix to all URLs generated by CodeIgniter. 
| For more information please see the user guide: 
| 
| http://codeigniter.com/user_guide/general/urls.html 
*/ 

$config['url_suffix'] = ''; 

/* 
|-------------------------------------------------------------------------- 
| Default Language 
|-------------------------------------------------------------------------- 
| 
| This determines which set of language files should be used. Make sure 
| there is an available translation if you intend to use something other 
| than english. 
| 
*/ 
$config['language'] = 'english'; 

/* 
|-------------------------------------------------------------------------- 
| Default Character Set 
|-------------------------------------------------------------------------- 
| 
| This determines which character set is used by default in various methods 
| that require a character set to be provided. 
| 
*/ 
$config['charset'] = 'UTF-8'; 
+0

我面對 這個問題。我感到沮喪..所有htaccess和代碼工作很好,但在不同的服務器上使用子域..不工作!解決的辦法是在你的apache設置中啓用mod_rewrite並解決我的問題! –

回答

2

.htaccess文件看起來不錯,請打開此文件application/config/config.php

並搜索$config['base_url'] = 'http://subdomain.domain.com';並填寫右側信息。

.htaccess文件應在根文件夾(除了與applicationsystem文件夾)

我自己.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 ^(.*)$ /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 ^(.*)$ /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] 
</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> 

和前幾行config.php

<?php if (! defined('BASEPATH')) exit('No direct script access allowed'); 


//$config['base_url'] = 'http://localhost/bz'; //development 
$config['base_url'] = 'http://bz.real-hosting.ufo'; //real dope 

/* 
|-------------------------------------------------------------------------- 
| Index File 
|-------------------------------------------------------------------------- 
| 
| Typically this will be your index.php file, unless you've renamed it to 
| something else. If you are using mod_rewrite to remove the page set this 
| variable so that it is blank. 
| 
*/ 
$config['index_page'] = ''; 

/* 
|-------------------------------------------------------------------------- 
| URI PROTOCOL 
|-------------------------------------------------------------------------- 
| 
| This item determines which server global should be used to retrieve the 
| URI string. The default setting of 'AUTO' works for most servers. 
| If your links do not seem to work, try one of the other delicious flavors: 
| 
| 'AUTO'   Default - auto detects 
| 'PATH_INFO'  Uses the PATH_INFO 
| 'QUERY_STRING' Uses the QUERY_STRING 
| 'REQUEST_URI'  Uses the REQUEST_URI 
| 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO 
| 
*/ 
$config['uri_protocol'] = 'AUTO'; 
+0

這就是我的配置文件看起來像 – Omade

+0

$ config ['base_url'] \t ='http://www.favouritememories.abovetheblues.co.uk/'; – Omade

+0

請嘗試以下命令:$ config ['base_url'] ='http://favouritememories.abovetheblues.co.uk/';' – Kyslik

相關問題