hassanzohdy / advanced-php-mvc-blog

A simple and a powerful OOP-written concept to create a blog using PHP
30 stars 15 forks source link

Nice project, but not work #4

Open ghost opened 3 years ago

ghost commented 3 years ago

Hi and thanks for your project, but unfortunately it doesn't seem to work. This is the problem it gives Cattura and the links do not work and always refer to the home by adding a double slash.

For example, if I click on login it results: www.mvc3.local//login with a double slash form www.mvc3.local and login. See the screenshot.

I have tested with many php version: from 5.6.40 to 8.0.6

hassanzohdy commented 3 years ago

Hello adrix71,

It doesn't seem to me the error message from your screenshot.

I would recommend using xampp instead of wamp.

Put your current code on a gist or a repository to check it.

Also install latest version of it.

ghost commented 3 years ago

Hello and thanks for the reply.

To tell the truth I have not made any changes to the code, but I only installed the version present in your repository on github; I suppose it is the most up-to-date version.

As for xampp unfortunately it is not possible for me to install it and I have to use wampp for many other reasons.

What could be the cause of the fact that only the homepage works?

hassanzohdy commented 3 years ago

What happens when you manually change the url to the login route?

ghost commented 3 years ago

I had thought about it too and it was the first attempt, but nothing changes even by manually setting the url

hassanzohdy commented 3 years ago

I just cloned the repository and imported the database associated with it and it works fine with me.

ghost commented 3 years ago

I did the same thing by cloning the repository and importing the database, but for the second time it gives me the same problem.

I don't really understand what it can come from. Do you have to recommend some version of PHP and Apache in particular? Have you ever seen those.

hassanzohdy commented 3 years ago

Try using version 7.4.

Also i can not see any error message in that trace list.

What does the home page you've look like?

bjenmonk commented 3 years ago

try this

/**
 * Prepare url
 *
 * @return void
 */
public function prepareUrl()
{
    $script = dirname($this->server('SCRIPT_NAME'));
    $requestUri = $this->server('REQUEST_URI');

    if (strpos($requestUri, '?')!==false) {
        list($requestUri,$queryString) = explode('?',$requestUri);
    }
    $this->url = rtrim(preg_replace('#^'.$script.'#', '' , $requestUri), '/');
    if (! $this->url){
        $this->url = '/';
    }

    $this->baseUrl=$this->server('REQUEST_SCHEME') . '://'.$this->server('HTTP_HOST') . $script .'/';

}