简体   繁体   中英

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. I have the same structure in my PHP code as well as in MySQL db. However, the PHP code doesn't execute when I click the links, it only works on my home page. I get the following error:

HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

Is this an IIS configuration problem?

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.

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. I hope this helps someone else.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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