abdulkrm

Trailing Slash expt wp-json in .htaccess

Sep 29th, 2023
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. REPLACE THIS :
  2.  
  3. # Redirection en ajoutant des slashs au urls
  4. RewriteCond %{REQUEST_FILENAME} !-f
  5. RewriteRule ^(.*[^/])$ /$1/ [R=301,L]
  6.  
  7. WITH THIS :
  8.  
  9. <IfModule mod_rewrite.c>
  10. RewriteEngine On
  11.  
  12. # Exclude URLs containing wp-json
  13. RewriteCond %{REQUEST_URI} !^/wp-json/ [NC]
  14.  
  15. # Condition to check the requested URL does not correspond to an existing file.
  16. RewriteCond %{REQUEST_FILENAME} !-f
  17.  
  18. # Rule to append a trailing slash to URLs not ending with one.
  19. RewriteRule ^(.*[^/])$ /$1/ [R=301,L]
  20. </IfModule>
  21. With the modified rule, any URL containing wp-json will be exempted from the trailing slash addition.
Advertisement
Add Comment
Please, Sign In to add comment