我有一个网址:https://example.com//seo/,我想去掉TLD后面的双斜杠,并重定向到https://example.com/seo/
我在Wordpress .htacces中使用了这段代码,但没有正常工作(不是重定向双斜杠):
我在Worpdress上的.htaccess上的完整当前代码,也许它会有所帮助:
# Delete double slash
<IfModule mod_rewrite.c>
RewriteBase /
RewriteCond %{THE_REQUEST} \s/{2,}
RewriteRule (.*) $1 [R=301,L]
RewriteCond %{REQUEST_URI} ^(.*)/{2,}(.*)$
RewriteRule (.*) %1/%2 [R=301,L]
</IfModule>
# 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
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# BEGIN WP-HUMMINGBIRD-CACHING
# Direktivy (řádky) mezi 'BEGIN WP-HUMMINGBIRD-CACHING' a 'END WP-HUMMINGBIRD-CACHING' jsou
# dynamicky generované a měly by být upravovány pouze pomocí filtrů WordPressu.
# Veškeré změny směrnic mezi těmito značkami budou přepsány.
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault A0
<FilesMatch "\.(txt|xml|js)$">
ExpiresDefault A31536000
</FilesMatch>
<FilesMatch "\.(css)$">
ExpiresDefault A31536000
</FilesMatch>
<FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav|mp4|m4v|ogg|webm|aac|eot|ttf|otf|woff|svg)$">
ExpiresDefault A31536000
</FilesMatch>
<FilesMatch "\.(jpg|jpeg|png|gif|swf|webp)$">
ExpiresDefault A31536000
</FilesMatch>
</IfModule>
<IfModule mod_headers.c>
<FilesMatch "\.(txt|xml|js)$">
Header set Cache-Control "max-age=31536000"
</FilesMatch>
<FilesMatch "\.(css)$">
Header set Cache-Control "max-age=31536000"
</FilesMatch>
<FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav|mp4|m4v|ogg|webm|aac|eot|ttf|otf|woff|svg)$">
Header set Cache-Control "max-age=31536000"
</FilesMatch>
<FilesMatch "\.(jpg|jpeg|png|gif|swf|webp)$">
Header set Cache-Control "max-age=31536000"
</FilesMatch>
</IfModule>
# END WP-HUMMINGBIRD-CACHING发布于 2020-10-07 00:46:42
检查这是否可以工作。
<IfModule mod_alias.c>
RedirectMatch 301 ^//(.*)$ http://example.com/$1
</IfModule>https://stackoverflow.com/questions/64229242
复制相似问题