CodeIgniter Route适用于CIFS安装,但不适用于本地文件

时间:2016-01-27 20:26:05

标签: php linux codeigniter routes mount

我们的工作环境使用带有apache / php的单个centos机器,为CIFS挂载和本地目录提供不同的虚拟主机。我们的应用程序是使用CodeIgniter 2.0构建的

我们最近对路由进行了更改,这些路由适用于为已安装驱动器提供服务的虚拟主机,但无法解析本地文件的路由,从而产生404.

$config['base_url'] = "http://production.host.com"; // the production value of $_SERVER['SERVER_NAME'] essentially

路线:

$route['companyone'] = 'sso/platformsso/requestgenericsso/companyone';
$route['companyone/(:any)'] = 'sso/ptlatformsso/requestgenericsso/companyone/$1';

这适用于以下场景:

<VirtualHost 192.168.1.1:80>
    ServerAdmin me@host.com
    DocumentRoot "/var/mnt/a"
    ServerName "a.tmbc.com"
    ErrorLog logs/a.error.log
    Alias ssaml /var/simplesamlphp/www
</VirtualHost>
<Directory "/var/mnt/a">
    Options  FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

Directory populated using CIFS mount: mount -t cifs //1.2.3.4/a /var/mnt/a -o rw,username=un,password=pwd,uid=48 --verbose1

但不适用于此方案:

<VirtualHost 192.168.1.1:80>
    ServerAdmin me@host.com
    DocumentRoot "/var/www/html/b"
    ServerName "b.host.com"
    ErrorLog logs/b.error.log
    Alias ssaml /var/simplesamlphp/www
</VirtualHost>
<Directory "/var/www/html/b">
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

Directory populated using SVN checkout: svn checkout file:///var/svn/repo/trunk /var/www/html/b

htaccess的:

AddType text/x-component .htc

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # Restrict unused HTTP methods
    RewriteCond %{REQUEST_METHOD} !^(GET|POST|HEAD)
    RewriteRule .* - [R=405,L]

    # Forces SSL
    RewriteCond %{HTTPS} !=on
    RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    #Removes access to the system folder by users.
    RewriteCond %{REQUEST_URI} ^_sys.*
    RewriteRule ^(.*)$ /index.php/$1 [L]

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

    RewriteRule ^(.*).(pdf|exe|doc|mp4)$ /externaldownload/?fileLocation=$1.$2 [R,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>

为什么会出现这种情况的任何想法?

1 个答案:

答案 0 :(得分:0)

我想我在这里理解你的问题。问题似乎出现在(:any)您的路线规则上。

$route['companyone/(:any)'] = 'sso/ptlatformsso/requestgenericsso/companyone/$1';

companyone作为第一段网址的网址,第二段的任何内容都会重新映射到sso/ptlatformsso/requestgenericsso/companyone/$1

似乎codeigniter将$1作为变量传递给函数companyone,这意味着您实际上正在匹配任何路由以强制重写。

如何将这些内容用于路由规则并制作

$route['(.*)'] = "sso/ptlatformsso/requestgenericsso/companyone/$1";

或只有一条规则用于

等路线
$route['companyone/(:any)'] = 'sso/ptlatformsso/requestgenericsso/companyone/$1';