I use a cloud server called Digital Ocean . However I'm having trouble trying to create friendly URLs. I activated the module rewrite
through the command:
sudo a2enmod rewrite
and changed sudo nano /etc/apache2/sites-available/default
thus leaving:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
If, by chance, there is a file with the same name, it does not pass through my .htacess
, regardless of the extension
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ sessao.php [NC,L,QSA]
Here too my sessoes.php
:
$gets = explode("/",str_replace(strrchr($_SERVER["REQUEST_URI"], "?"), "", $_SERVER["REQUEST_URI"]));
for($i=1; $i<=count($gets); $i++) {
$var = "p$i";
$$var = addslashes($gets[$i]);
}
if (file_exists($p1.".php")) {
include("teste.$p1".".php");
} else {
header("Location: /");
exit();
}
Practical example of the situation:
If I call http://107.170.237.146/base
it loads http://107.170.237.146/base.html
if it finds the same, if it does not find it search http://107.170.237.146/base.php
, if it does not find it it loads sessoes.php
.
But I can check that it always passes first through sessoes.php
and then fall into .html or .php.
How can I make it first obey .htaccess
?