简体   繁体   中英

Apache2 Module Rewrite it is not working as it should

I created an MVC system in PHP and use the Apache Rewrite module to protect some folders and compose URL's.

I created the base on my development machine that I use Xampp and I even used the same system on an online server (client) and everything works fine.

But I want to have this same MVC system on the server that we set up in the company where I work for other developers to use it, but this server is not working properly.

On the server giving this problem, I have installed Ubuntu 20.04 (Desktop), Apache 2, PHP 7.4.13 and MySQL. I have already enabled the Rewrite module.

And I'm using the same .htaccess that I'm using both on my machine (Windows) and on the server that is online (public webserver) Linux.

Below the .htaccess files I'm using

That first .htaccess file I use to always redirect the client into the public folder

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^$ public/ [L]
    RewriteRule (.*) public/$1 [L]
</IfModule>

This second is inside the public folder and is to compose the URL

<IfModule mod_rewrite.c>
    Options -Multiviews
    RewriteEngine On
    RewriteBase /criate/public
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
</IfModule>

The latter is inside the App folder and I use them to not have access to that folder

Options -Indexes

My Apache default.conf file

    <Directory "/var/www/html">
      Options Indexes FollowSymLinks
      AllowOverride All
      Order allow, deny
      allow from all
      Require all granted
   </Directory>

But what is happening, when accessing the project url, let's assume it is: https://api.aplication.com

Works perfectly well, takes me to the application home with all right. But when I click the login button, for example. Give me the following error.

Not Found The request URL was not found on this server

But there is, because I made a copy of the project that is working both on Windows and on the online server that is Linux too.

What configuration do I have to see and analyze to resolve this issue?

In phpinfo it says what module is active. Thanks

I already found what I was doing wrong in the .htaccess files, follow what I changed, that in all .htaccess files.

RewriteEngine On
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]

Options -Multiviews
RewriteEngine On
RewriteBase /criate/public
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

It was just removing the conditions that check if the module is active or not, I will study further to find out how to do these conditions in LINUX.

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