新服务器的CodeIgniter URL重定向问题

时间:2014-01-15 07:03:34

标签: php .htaccess codeigniter

最近我们搬到了新的托管服务器。在那里我们的网站没有运行;它只是显示一个空页面,

这是我的.htaccess文件

RewriteEngine on

#RewriteCond %{REQUEST_URI} !=/maintenance.html
#RewriteRule ^ /maintenance.html [R=301]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php/$1 [L,QSA]


<IfModule mod_expires.c>

    ExpiresActive On

    ExpiresByType text/html "access plus 10 seconds"

    ExpiresByType image/gif "access plus 10 years"

    ExpiresByType image/jpeg "access plus 10 years"

    ExpiresByType image/png "access plus 10 years"

    ExpiresByType image/x-icon "access plus 10 years"

    ExpiresByType text/css "access plus 10 years"

    ExpiresByType text/javascript "access plus 10 years"

    ExpiresByType application/x-javascript "access plus 10 years"

    ExpiresByType application/x-shockwave-flash "access plus 10 years"

</IfModule>

<IfModule mod_rewrite.c>

    RewriteEngine On
    RewriteBase /


    RewriteRule ^(welcome(/index)?|index(\.php)?)/?$ / [L,R=301]
    RewriteRule ^(.*)/index/?$ $1 [L,R=301]


    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)/$ $1 [L,R=301]


    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php/$1 [L]


    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]

</IfModule>

<IfModule !mod_rewrite.c>

    ErrorDocument 404 /index.php

</IfModule>
#RedirectMatch \.(dynamiccontent|pl|plx|perl|cgi|php|php4|php4|php6|php3|shtml)$...

这是我的config.php文件:

<?php
    if ( ! defined('BASEPATH'))
        exit('No direct script access allowed');
    $config['base_url'] = 'http://tollywood.net/';
    $config['index_page'] = "";
    $config['uri_protocol'] = 'REQUEST_URI';
    $config['url_suffix'] = '.htm';
    $config['language'] = 'english';
    $config['charset'] = 'UTF-8';
    $config['enable_hooks'] = FALSE;
    $config['subclass_prefix'] = 'MY_';
    $config['permitted_uri_chars'] = 'a-z 0-9~%.:_\(\)\-\'\ \,\+';
    $config['allow_get_array']     = TRUE;
    $config['enable_query_strings'] = FALSE;
    $config['controller_trigger']   = 'c';
    $config['function_trigger']     = 'm';
    $config['directory_trigger']    = 'd'; // experimental not currently in use
    $config['log_threshold'] = 0;
    $config['log_path'] = '';
    $config['log_date_format'] = 'Y-m-d H:i:s';
    $config['cache_path'] = '';
    $config['encryption_key'] = 'abcdefgh1234';
    $config['sess_cookie_name']     = 'ci_session';
    $config['sess_expiration']      = 7200;
    $config['sess_expire_on_close'] = FALSE;
    $config['sess_encrypt_cookie']  = FALSE;
    $config['sess_use_database']    = FALSE;
    $config['sess_table_name']      = 'ci_sessions';
    $config['sess_match_ip']        = FALSE;
    $config['sess_match_useragent'] = TRUE;
    $config['sess_time_to_update']  = 300;
    $config['cookie_prefix']    = "";
    $config['cookie_domain']    = "";
    $config['cookie_path']      = "/";
    $config['cookie_secure']    = FALSE;
    $config['global_xss_filtering'] = FALSE;
    $config['csrf_protection'] = FALSE;
    $config['csrf_token_name'] = 'csrf_test_name';
    $config['csrf_cookie_name'] = 'csrf_cookie_name';
    $config['csrf_expire'] = 7200;
    $config['compress_output'] = FALSE;
    $config['time_reference'] = 'local';
    $config['rewrite_short_tags'] = FALSE;
    $config['proxy_ips'] = '';

    /* End of file config.php */

    /* Location: ./application/config/config.php */

在config.php文件中,我尝试使用新的IP地址更改基本URL。然后它也没有用。

http://ipaddress/~tollywoo/ If we type this in the browser, it is showing a blank page

http://ipaddress/~tollywoo/index.php/News.htm  here it is working

如何解决此问题?

2 个答案:

答案 0 :(得分:0)

尝试将重写基础从/更改为/~tollywoo/

此外,最底层的规则可能不会被执行,因为顶部的第一条规则将所有内容路由到index.php,这将绕过其他规则尝试的所有内容。

答案 1 :(得分:0)

试试这个.htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_URI} ^sys.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_URI} ^app.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>

假设 index.php 是您的索引页。

并在config.php中更改:

$config['index_page'] = '';