简体   繁体   English

从Apache迁移后,IIS7上的链接错误

[英]Link error on IIS7 after a migration from Apache

I migrated a PHP application from Apache to IIS7, all the links are loaded from a MySQL table record that contains the path directory. 我将PHP应用程序从Apache迁移到IIS7,所有链接均从包含路径目录的MySQL表记录中加载。 I have the same structure in my PHP code as well as in MySQL db. 我的PHP代码和MySQL数据库具有相同的结构。 However, the PHP code doesn't execute when I click the links, it only works on my home page. 但是,当我单击链接时,PHP代码不会执行,仅在我的主页上有效。 I get the following error: 我收到以下错误:

HTTP Error 404.0 - Not Found HTTP错误404.0-找不到
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. 您要查找的资源已被删除,名称已更改或暂时不可用。

Is this an IIS configuration problem? 这是IIS配置问题吗?

This is for the home page: 这是主页:

<ul>                  
<?php
echo $class->menu->topmenu( $patharray[0] ) ?>                                        
</ul>

The following is for the link: 以下是链接:

function topmenu ( $path = 'home' )
    {
        $home = $this->fetchOne ( $this->query( "SELECT * FROM admin_menu WHERE parent = 0" ) ) ;
        $links = $this->fetch ( $this->query ( "SELECT admin_menu.*, aus.value FROM admin_menu LEFT JOIN admin_user_status aus ON ( aus.id = admin_menu.status ) WHERE parent = 1 AND active ='yes'  ORDER BY sort ASC" ) ) ;

        if ( $links )
            foreach ( $links as $key => $link )
            {

                if ( $key == 0)
                    $url = '/';


                else 
                    $url = $link->url;

                //if ( $link->priv == 'open' || ( $link->priv == 'private' && $this->userinfo->status == 225 ) )
                if( $this->check_user_priv( $link ) )
                {
                    if( stripos( $link->url, $path ) === false )
                        $result .= "<li class='mainlevel'><a href='$url'  >$link->text</a></li>" ;
                    else 
                        $result .= "<li class='mainlevel'><b><a href='$url'  >$link->text</a></b></li>" ;
                }


            }


return $result; 
}

The url links above are loaded from the table, but when I click on them I get the HTTP Error 404.0 - Not Found. 上面的URL链接是从表中加载的,但是当我单击它们时,我收到HTTP错误404.0-未找到。

I solved my problem by importing Apache mod_rewrite Rules into the URL Rewrite Module in IIS 7. My migration from Apache had .htaccess rules that needed to be converted for the web.config. 我通过将Apache mod_rewrite规则导入IIS 7中的URL重写模块解决了我的问题。我从Apache进行的迁移具有.htaccess规则,需要将其转换为web.config。 I hope this helps someone else. 我希望这可以帮助其他人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM