如何解决使用.htacces在Wordpress中删除域名TLD之后的双斜杠
我有以下URL: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
解决方法
检查是否可以正常工作。
<IfModule mod_alias.c>
RedirectMatch 301 ^//(.*)$ http://example.com/$1
</IfModule>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。