【问题标题】:CodeIgniter URL redirect issues for new server新服务器的 CodeIgniter URL 重定向问题
【发布时间】:2014-01-15 07:03:34
【问题描述】:

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

这是我的 .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

我该如何解决这个问题?

【问题讨论】:

    标签: php .htaccess codeigniter


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      试试这个 .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'] = '';
      

      【讨论】:

        猜你喜欢
        • 2015-11-12
        • 1970-01-01
        • 2016-07-02
        • 1970-01-01
        • 2015-04-15
        • 2019-02-20
        • 2011-09-25
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多