dpicx06888 2015-12-22 13:41
浏览 55

CodeIgniter路由不使用子域

I have CodeIgniter application that I transferred to a subdomain: customer.domain.com/application-name/

Now when I access the above URL, I can see the login page and links to images etc. work.

What doesn't work, however, is routing. It returns a 500 server error because what it tries to do is access:

customer.domain.com/customer/class/method

So as you can see, somehow the subdomain is appended to the url. This should not be the case. The configured base path should be used. So I would expect it to access:

customer.domain.com/application-name/class/method

.

I have the feeling I need to add something in my .htaccess file, but I'm not quite sure what to do.

My config.php file:

$route['default_controller'] = "pub";
$route['404_override'] = '';

$route['welcome'] = 'pub/welcome';
$route['send_new'] = 'pub/send_new';
$route['cron'] = 'pub/cron';
$route['invitation/(:any)'] = 'pub/invitation/$1';
$route['unsubscribe/(:any)'] = 'pub/unsubscribe/$1';
$route['widget/(:any)'] = 'pub/widget/$1';
$route['excel-tpl'] = 'pub/excel_tpl';
$route['pub/(:any)'] = 'pub/$1';
$route['pub/(:any)/(:any)'] = 'pub/$1/$2';
$route['(:any)'] = 'pub/short_url/$1';

My .htaccess file:

RewriteEngine on
RewriteRule \.(js|css)$ - [L]

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

I hope you guys can help me out.

  • 写回答

1条回答 默认 最新

  • dongyue7796 2015-12-22 15:44
    关注

    Try adding

    RewriteEngine on
    RewriteRule \.(js|css)$ - [L]
    
    RewriteCond %{HTTP_HOST} !^customer\.domain\.com [NC]
    RewriteRule ^(.*)$ http://customer.domain.com/$1 [L,R=301]
    
    RewriteCond    %{REQUEST_FILENAME}    !-f 
    RewriteCond    %{REQUEST_FILENAME}    !-d 
    RewriteRule    ^(.*)$ index.php?$1 [QSA,L]
    

    to .htaccess file.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog