2

I have a website made with wordpress https://example.es/ and I'd like to remove the final slash. My .htaccess looks like this:

RewriteCond %{REQUEST_URI} !wp-admin
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.es$ [NC]
RewriteCond %{REQUEST_URI} jh73820h.htm$ [NC]
RewriteRule .* - [L]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://example.es/$1 [R=301,L,QSA]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

I found this code and it removes the final slash but it appears a 404 error.

Options +FollowSymlinks
RewriteCond %{REQUEST_URI} !wp-admin
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.es$ [NC]
RewriteCond %{REQUEST_URI} jh73820h.htm$ [NC]
RewriteRule .* - [L]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://example.es/$1 [R=301,L,QSA]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)/$ https://www.example.es/$1 [R=301,L,QSA]
</IfModule>

# END WordPress

Does anybody know what can I do not to get a 404 error?

Anna
  • 126
  • 1
  • 1
  • 10

1 Answers1

0

Try this:

 // BEGIN WordPress
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]

    RewriteRule (.+)/$ $1 [R=301,L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>
chiefo
  • 281
  • 1
  • 5
  • 15
  • If it doesn't work try this one: // BEGIN WordPress RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteRule (.+)/$ http://www.domain.com/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] – chiefo Dec 18 '16 at 15:08
  • both ways work thanks! but the browser says that I have a lot of redirections so the page can't be loaded, do you know what can I do? @chiefo – Anna Dec 18 '16 at 15:28
  • uhhmm try searching around but that is what works for me tho – chiefo Dec 18 '16 at 15:43