htaccess RewriteRule doesn't prettify my URLs

55 Views Asked by At

I have a Droplet on DigitalOcean, Ubuntu 22.04, SSL enabled, the site runs smoothly and mod_rewrite is on

Here's my apache2.conf:

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>

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

And here's my .htaccess file:

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^profile/([^/]*)$ /profile.php?user=$1 [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^getpro/([^/]*)$ /getpro.php?userID=$1 [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^play/([^/]*)$ /play.php?cID=$1 [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^subdetails/([^/]*)$ /subdetails.php?sub=$1 [NC,L]

None of those rules work, let's take the first one just as example, here's the original URL:

https://example.com/profile.php?user=johndoe

It should allow me to use: https://example.com/profile/johndoe, but it doesn't, this is what I get:

enter image description here

I've restarted apache, rebooted the server, waited for hours just to make sure the server needed some time to process my changes, never got a positive result

PS: For instance, if I use this line for the profile redirect:

RewriteRule ^(.*)$ /profile.php?user=$1

and I call: example.com/johndoe, the redirect works.

So I don't understand why the redirect to the profile.php file doesn't work

0

There are 0 best solutions below