0

I need to remove trailing slash from URLs ending with .xml/ only .. For this purpose I've created a Rewrite Condition and Rule which is working perfectly fine for the test link http://website.com/test.xml/

Test Link: http://htaccess.mwl.be?share=6fe08232-438a-53fa-8f1a-1f7f69b77b6f

The problem is when I place the rule in WordPress .htaccess file, it doesn't work at all! Seems like WordPress or YOAST Permalink structure is overriding the rule .. please help!

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} /(.*).xml/$
RewriteRule ^ /%1.xml [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Hassan Alvi
  • 133
  • 1
  • 8
  • If it's a problem with one of those plugins causing a conflict, you may want to ask on sister site: https://wordpress.StackExchange.com – SherylHohman Dec 27 '17 at 09:40
  • @SherylHohman just need to verify if the `.htaccess` file is correct? – Hassan Alvi Dec 27 '17 at 11:57
  • 1
    Question Moved to WordPress StackExchange .. https://wordpress.stackexchange.com/questions/289582/htaccess-remove-trailing-slash-from-url-ending-with-xml-only – Hassan Alvi Dec 27 '17 at 12:01

1 Answers1

0

Use the following code in your htacess file: RewriteRule (.+)/$ $1 [R=301,L]
RewriteCond %{REQUEST_URI} /(.*).xml/$
RewriteRule ^ /%1.xml [L]

If not working then download new wordpress and try in that.

TBI
  • 2,789
  • 1
  • 17
  • 21