简体   繁体   English

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

[英]CodeIgniter URL redirect issues for new server

Recently we moved to a new hosting server. 最近,我们移至新的托管服务器。 On there our website is not running; 在该网站上,我们的网站未运行; it is simply showing an empty page, 它只是显示一个空白页,

Here is my .htaccess file 这是我的.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)$...

Here is my config.php file: 这是我的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 */

In the config.php file I tried changing the base URL with the new IP address. 在config.php文件中,我尝试使用新的IP地址更改基本URL。 Then also it is not working. 然后它也不起作用。

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

but

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

How can I fix this problem? 我该如何解决这个问题?

Try changing your rewrite base from / to /~tollywoo/ . 尝试将您的重写基础从/更改为/~tollywoo/

Also, the rules at the very bottom probably aren't going to get executed because the first rule at the top routes everything to index.php , which will bypass everything the other rules are trying to do. 另外,最底层的规则可能不会执行,因为最顶层的第一个规则将所有内容路由到index.php ,这将绕过其他规则尝试执行的所有操作。

Try this .htaccess: 试试这个.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>

Assuming that index.php is your index page. 假设index.php是您的索引页面。

And change in config.php: 并更改config.php:

$config['index_page'] = '';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM