我们在工作中的开发环境使用一台带有 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>
有什么想法吗?
我想
我在这里理解你的问题。问题似乎出在您的路线规则(:any)
。
$route['companyone/(:any)'] = 'sso/ptlatformsso/requestgenericsso/companyone/$1';
以 companyone
作为 URL 的第一段的 URL 和第二段的任何内容都将重新映射到sso/ptlatformsso/requestgenericsso/companyone/$1
似乎代码点火器将$1
作为变量传递给函数companyone
这意味着您实际上正在匹配那里的任何路由以强制重写。
如何将它们压缩为路由规则并制定
$route['(.*)'] = "sso/ptlatformsso/requestgenericsso/companyone/$1";
或者只有一个路由规则,例如
$route['companyone/(:any)'] = 'sso/ptlatformsso/requestgenericsso/companyone/$1';