-1

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]
Ivan
  • 99
  • 3
  • Nothing in the Apache config you've posted would cause this. What do you see in the network traffic? Some kind of 3xx redirect I assume? What is the status? And to confirm, _both_ slashes are "removed"? What is the HTML of the link in question? – MrWhite Sep 28 '21 at 09:22
  • I followed to confirm the slash is removed... so I discovered the cause, edited my question – Ivan Sep 28 '21 at 09:28
  • "I discovered the cause" - So, what is the "cause"? You've described the _effect_ in the question, not the "cause"? (If you know the "cause" then you are close to a solution.) Please address _all_ the points asked in my comment above. However, the first rule in your config _removes_ the www subdomain, but all your examples (including the resulting URL) include the www subdomain? Please confirm. – MrWhite Sep 28 '21 at 09:57
  • Sorry, and yes, the effect since you suggested me to confirm the slash. It removes the www subdomain which is fine because it is not part of the issue. – Ivan Sep 28 '21 at 21:06
  • "It removes the www subdomain which is fine because it is not part of the issue." - or is it? That is the only redirect you have in the config you posted. So, is there an _additional_ redirect that removes the slashes? What exactly do you see in the network traffic? – MrWhite Sep 28 '21 at 21:12
  • Well, the truth is that I don't have any knowledge about network traffic, the reason why I ask a question here because I am not an expert in networking – Ivan Sep 28 '21 at 21:28
  • 1
    Open the browser developer tools (eg. in Google Chrome), go to the "Network" tab (check "Disable cache"), make a request to `domain.com/ja/` and record the results... these are the HTTP requests and responses the browser is making. This should give you a clue as to what is actually happening... how many redirects are being triggered, what type and what is triggering them (check the HTTP response headers on the redirect response). This is the first step to debugging an issue like this. – MrWhite Sep 28 '21 at 23:00

1 Answers1

1

I am only can think 3 possible reasons:

  1. Your browser cached 301 redirect from an old rewrite rule or something similar. Try to access the URL from other browser to confirm it.

  2. The redirector is from the Wordpress/or the plugin. Try to disable all plugin first or change index.php to empty file.

  3. 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]
  • The issue is when you click "www.domain.com/ja/" then it redirects to the page with your browser ended up with "www.domain.comja" – Ivan Sep 28 '21 at 09:30
  • 1
    @Ivan Sorry for missunderstood, I updated the answer – Muhammad Dyas Yaskur Sep 28 '21 at 12:06
  • Regarding to reason 1#: I enter https://www.example.com/ja it redirects me to https://www.example.com/opt/bitnami/apps/wordpress/htdocs/ja in other browser – Ivan Sep 28 '21 at 21:42
  • Reason #2 the current wordpress site is not using redirector plugin and the index.php is required to load wordpress header. Reason #3 I copypasted your code and restarted the apache server, then the most directory like /ja/ were not found – Ivan Sep 28 '21 at 21:49