remove trailing slash from sub-directory multisite
-
Hi,
Have migrated a subdirectory multisite from Nginx to LiteSpeed, but I cannot figure out how to configure the htaccess rules.
Simply the situation is that I need to 301 from
abc.com/site1/a/
toabc.com/site1/a
without the end trailing slash.I have tried most of the lines on the internet I can possibly find, they can work 301 for pages but cannot fix the too many redirect problem for
wp-admin/
urls.The original htaccess is as follows:
# BEGIN WordPress # The directives (lines) between "BEGIN WordPress" and "END WordPress" are # dynamically generated, and should only be modified via WordPress filters. # Any changes to the directives between these markers will be overwritten. <IfModule mod_rewrite.c> RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase / RewriteRule ^index\.php$ - [L] # add a trailing slash to /wp-admin RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L] RewriteRule . index.php [L] </IfModule> # END WordPress
I have tried rules like:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)/$ /$1 [R=301,L]
<IfModule mod_rewrite.c> RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} (.+)/$ RewriteRule ^ %1 [R=301,L]
Most of the time, these rules can work well for the main site
abc.com/wp-admin/
but will cause a redirect loop for sub-directory sites:abc.com/site1/wp-admin/
Can anyone help with a doable redirect rule? thanks!
- The topic ‘remove trailing slash from sub-directory multisite’ is closed to new replies.