URL trailing slash gets removed

275 Views Asked by At

I recently found a bug that when i go to example.com/phpmyadmin or example.com/index the trailing slash gets removed, so it's calling example.comphpadmin or example.comindex. This happens with everything after the slash. But if i have a second trailing slash like example.com/index/home it works perfectly.

I have a redirect from http to https active in my site config, running apache2.4.

My config:

<VirtualHost *:80>
    ServerName example.net
    Redirect permanent / https://example.net
</VirtualHost>

And my .htaccess:

<IfModule mod_rewrite.c>
  RewriteEngine On
  # !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
  #  slashes.
  # If your page resides at
  #  http://www.example.com/mypage/test1
  # then use
  # RewriteBase /mypage/test1/
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond $1 !^(phpmyadmin|index\.php|images|robots\.txt)
  RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
  # If we don't have mod_rewrite installed, all 404's
  # can be sent to index.php, and everything works as normal.
  # Submitted by: ElliotHaughin

  ErrorDocument 404 /index.php
</IfModule>

I looked around but found no answers. Maybe there is something wrong with my config and somebody could help me.

2

There are 2 best solutions below

0
On

Considering that this RewriteRule doesn't even execute for /phpmyadmin due to the RewriteCond, and the RewritRule doesn't redirect, the problem is a bug in whoevers index.php you're sending all the unknown resources to.

Or, you've not shown us the actual configuration.

0
On

I was being dumb and just had to clear the cache to get it working. I don't know what exactly wasn't working but my changes i made before making this post did work out, just the cache still had the faulty version in it.