How to fix domain redirect with slash using Apache2 and Bitnami?
I'm running a Wordpress website with Bitnami which confused me a lot of ways.
The issue is when you click a link www.domain.com/ja/ then it goes to www.domain.comja because there is a missing slash /
EDIT: I discovered how it handles www.domain.com/ja without "/" in the last works fine as I expected, otherwise www.domain.com/ja/ with "/" slash it ended up with www.domain.comja
I've tried a lot of ways to solve this issue and still no solution.
Here is my apache2 conf from /opt/bitnami/apps/wordpress/conf/httpd-app.conf
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1/ [R=permanent,L]
RewriteRule ^index\.php$ - [S=1]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
I am only can think 3 possible reasons:
-
Your browser cached 301 redirect from an old rewrite rule or something similar. Try to access the URL from other browser to confirm it.
-
The redirector is from the Wordpress/or the plugin. Try to disable all plugin first or change
index.php
to empty file. -
You still have the wrong rule like:
RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} /(.+)/$ RewriteRule ^ https://www.example.com%1 [L,R=301]
above will redirect like your case, so change to:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]