【发布时间】:2016-05-04 23:51:33
【问题描述】:
我们工作中的开发环境使用一台带有 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>
任何想法为什么会这样?
【问题讨论】:
-
你能分享你的虚拟主机文件和你的
$config['base_url']设置吗? -
添加了该信息。感谢@PoX的帮助
-
我认为您遇到了 rewritemod/htaccess 相关问题,请检查这些问题或在此处分享,我们也许可以提供帮助。根据服务器名称,我假设它是
-
添加了
.htaccess。我们已经使用这个设置好几年了。最大的变化是 sso 路由值。路线,现在是 2 条,以前是一条线:$route['companyone'] = 'sso/companyone/requestSSO';
标签: php linux codeigniter routes mount