有关xampp中httpd.conf和vhost配置问题

httpd.conf


修改完成后的部分如下





httpd-vhosts.conf

修改内容如下

<VirtualHost *:81>  
    #配置访问跟目录  
    DocumentRoot "D:/XAMPP/htdocs/foxphp/foxphp"      
    ServerName web.foxphp.com  
    #这里配置欢迎首页面  
    DirectoryIndex news.html index.html index.htm index.php  
    <Directory />  
    Options FollowSymLinks  
    #不允许别人修改我们的页面  
    AllowOverride All  
    Allow from all
    Satisfy all 
    </Directory>  
</VirtualHost>  

_Master.inc

<?php
	//father of all controller class 
	abstract class _Master{


	}

?>
index.inc

<?php
	class index extends _Master{
		function showindex(){
			include (FOXPHP_PATH . "/MVC/View/" . FOXPHP_VIEWPATH. "/index.php");
		
		}
	}

?>

备注:这里的showindex方法要小写,然后url调用的时候也是小写,这样才正确,能找到对应的文件

我之前showIndex大写了,url也是调用的showIndex,当时发现找不到相应的文件。




在网站根目录下设置.htaccess文件

<ifmodule mod_rewrite.c>
 RewriteEngine on
 RewriteCond %{QUERY_STRING} ^(.*)
 RewriteRule ^([a-z]{2,10})/$ /index.php?controller=$1&%1  
 RewriteCond %{QUERY_STRING} ^(.*)
 RewriteRule ^([a-z]{2,10})\/([a-z]{1,20})/$ /index.php?controller=$1&action=$2&%1 
 </ifmodule>


host文件中设置 127.0.0.1 映射web.foxphp.com


<?php
	include("foxphp.conf");
	$_controller = isset($_GET["controller"])?$_GET["controller"]:""; // get controller
	$_action = isset($_GET["action"])?$_GET["action"]:"";  // get action, this parameter do not necessary 
	if($_controller == "" || in_array($_controller, explode(",", FOXPHP_FORBIDDEN_TYPE))) exit();
	//load overall functions
	include(FOXPHP_PATH . "/Common/functions.inc");

	include(FOXPHP_PATH . "/MVC/Controller/_Master.inc");
	include(FOXPHP_PATH . "/MVC/Controller/".$_controller.".inc");
	$_init_controller = new $_controller();
	$_init_controller->$_action();
?>


网址中键入http://web.foxphp.com:81/index/showindex/

就可以访问index文件了,转向到index类的showindex方法













参考链接  有关开设不同端口,进入不同网站

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值