Problems with Rewrite PHP / Apache

Asked

Viewed 60 times

1

02 days ago I moved from Linux distro and am now using Elementary OS. I installed Apache, Mysql and PHP manually, in the same way I installed it in the previous distro, but I have problems with Rewrite ( friendly urls ). In the previous distro it worked correctly, but in this distro it is not working. See below the . htaccess, which works correctly:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]

In the terminal I gave the following command:

sudo a2enmod rewrite

I restarted the Apache:

sudo systemctl restart apache2

Then in the file:

/etc/apache2/sites-available/000-default.conf

I included that block:

<Directory /var/www/html>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
</Directory>

Again I restarted Apache, but still the problem persists, IE, when I click on the site link: talk to us/, It shows that the page was not found. Remember that on the remote server and in the previous distro, it worked correctly and the file speaks to us.php exists.

inserir a descrição da imagem aqui

  • Try to give a chmod -R 777 inside your briefcase /var/www/html/

  • Hello Marcelo. I gave permission, but the problem persists.

  • You’ve already messed with the /etc/apache2/sites-available/000-default.conf because its configuration seems strange to me?

  • I change the /etc/apache2/apache2.conf and the /etc/apache2/sites-available/000-default.conf

  • The /etc/apache2/apache2.conf did not change. What kind of change should I make in this file?

  • I’m sorry, I couldn’t understand about the different setup you were talking about.

  • Tell me if you have solved the problem

  • Hi Marcelo. Nothing... is giving the same problem. I’ll do the following, I’ll reinstall everything, follow the tips you went through and see if the problem will persist.

Show 3 more comments

1 answer

2


This is my /etc/apache2/sites-available/000-default.conf

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    #DocumentRoot /var/www/html  # << ANTIGO
    DocumentRoot /home/user/Desenvolvimento/web

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    #REMOVI OS COMENTARIOS DESNECESSARIOS PARA A RESPOSTA
</VirtualHost>

/etc/apache2/apache2.conf

# .... alguns outros códigos também, mas o interesse é aqui

#<Directory /var/www/html/>     <<<DEFAULT  [padrão]
<Directory /home/user/Desenvolvimento/web/>  #TROQUE PARA o seu diretório desejado
    Options Indexes FollowSymLinks
    #AllowOverride None           <<< DEFAULT [pode ignorar]
    AllowOverride All
    Require all granted
</Directory>

#alguns outros códigos......
  • It worked Marcelo. I removed the code that was included in /etc/apache2/sites-available/000-default.conf as per your template and included the lines you mentioned. Thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.