.htaccess 使用尾部斜杠转发旧URL

.htaccess 使用尾部斜杠转发旧URL,.htaccess,mod-rewrite,hyperlink,seo,http-status-code-301,.htaccess,Mod Rewrite,Hyperlink,Seo,Http Status Code 301,我在WordPress上使用Divi builder已经有相当长的一段时间了。我长大了,改用Webflow,这样定制代码就更容易实现了。我已经得到了现场直播,但有一个重大问题 Divi Builder创建的URL如下所示 现在我的主机服务器上有了所有的站点文件,我得到的URL如下所示 很好的尝试,我相信你几乎做对了,你需要把你的https强制规则放在htaccess的顶部,否则它将是URL的完全重定向;更正了上次检查uri是否以/结尾的规则中的正则表达式,请尝试以下操作一次。公平的警告,我现在

我在WordPress上使用Divi builder已经有相当长的一段时间了。我长大了,改用Webflow,这样定制代码就更容易实现了。我已经得到了现场直播,但有一个重大问题

Divi Builder创建的URL如下所示

现在我的主机服务器上有了所有的站点文件,我得到的URL如下所示


很好的尝试,我相信你几乎做对了,你需要把你的https强制规则放在htaccess的顶部,否则它将是URL的完全重定向;更正了上次检查uri是否以
/
结尾的规则中的正则表达式,请尝试以下操作一次。公平的警告,我现在还不能测试它

放置此.htaccess文件后,请确保在测试URL之前清除浏览器缓存

# Force HTTPS and WWW 
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [OR,NC]
RewriteCond %{https} off  
RewriteRule ^(.*)$ https://www.hike2hike.com/$1 [R=301,L]


# Remove trailing slash from non-filepath urls
RewriteCond %{REQUEST_URI} ^/(.+)/$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ https://www.hike2hike.com/%1 [R=301,L]


# Include trailing slash on the directory 
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+)$ https://www.hike2hike.com/$1/ [R=301,L]

评论不用于扩展讨论;这段对话已经结束。
# Force HTTPS and WWW 
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [OR,NC]
RewriteCond %{https} off  
RewriteRule ^(.*)$ https://www.hike2hike.com/$1 [R=301,L]


# Remove trailing slash from non-filepath urls
RewriteCond %{REQUEST_URI} ^/(.+)/$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ https://www.hike2hike.com/%1 [R=301,L]


# Include trailing slash on the directory 
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+)$ https://www.hike2hike.com/$1/ [R=301,L]