简体   繁体   中英

Php mvc -link redirection issue

I have developed a web application using php (custom MVC). The web app works fine on the localhost but not on godaddy server.

I have written redirect function as following:

public function redirect($controllerName, $action, $params=null) {  

    if($controllerName){
        $link = Constant::$APP_URL . "/" . $controllerName. "/" . $action;      }else{          $link = Constant::$APP_URL  . "/" . $action;        }

    if($params != null) {
        $link .= "?" . http_build_query($params);
    }
    header("Location:" . $link);
    exit;
}

Take the following example:

The following on local server works, when I try to login:

https://localhost/project/login

If I type the same on my server, it does not work & redirects me to the following link:

https://example.com/login/login

"login" is a function in one of the controllers.

Any ideas?

My .htaccess file looks like:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule .* index.php [L,QSA]

hey could you please provide us with the error report from cpanel. if you go into your cpanel on godaddy then go to error log it should show a report at the specific time of action. like when the button pushed. if you have javascript as well and nothing shows up(which i doubt) also check google by right clicking and going inspect element. this will give more info for what is actually going on. from there we could source a solution or you might even be able to google possible solutions before you need to ask.

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