我以前的文件夹树是(使用便携式 xampp):(例如在 D:驱动器根目录上工作)
/xampp/htdocs/application
/xampp/htdocs/system
/xampp/htdocs/themes
/xampp/htdocs/index.php etc..
现在我正在尝试转变为一个可以处理多个项目的结构,因此是新树:
/xampp/htdocs
/web_projects/project-name/codeigniter/application
/web_projects/project-name/codeigniter/system
/web_projects/project-name/htdocs/themes
/web_projects/project-name/htdocs/index.php
我在 htdocs 中的htaccess文件:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)
# if Serves works on Linux OS
RewriteRule ^(.*)$ index.php/$1
# if Server works on Windows OS
# RewriteRule ^(.*)$ index.php?/$1
RewriteCond %{REQUEST_FILENAME} !-f
# if Serves works on Linux OS
RewriteRule ^(application|modules|plugins|system|themes|library|files) index.php/$1 [L]
# if Server works on Windows OS
# RewriteRule ^(application|modules|plugins|system|themes|library|files) index.php?/$1 [L]
和httpd-vhosts.conf:
NameVirtualHost *:8080
<VirtualHost *:8080>
DocumentRoot "/xampp/htdocs"
ServerName localhost
<Directory "/xampp/htdocs">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:8080>
DocumentRoot "/web_projects"
ServerName welcome.localhost
<Directory "/web_projects">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:8080>
DocumentRoot "/web_projects/test/htdocs"
ServerName test.localhost
<Directory "/web_projects/test/htdocs">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
最后等/主机:
127.0.0.1 localhost
127.0.0.1 welcome.localhost
127.0.0.1 test.localhost
127.0.0.1 vstart # Alias for test
所有虚拟主机都在工作,即http://vstart:8080/正在工作,但 codeigniter 在地址行中没有 index.php 时无法运行,因此路由无法正常工作。
我的config/config.php文件是:
$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
$config['base_url'] .= "://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['index_page'] = '';
这组在我以前的文件夹树中运行顺利,现在无法正常工作。我挖掘互联网以找到失败的解决方案。
有什么外眼可以捕捉到我做错的地方吗?