简体   繁体   English

将URL https://www.domain.com重定向到https://www.domain.com/

[英]redirect the URL https://www.domain.com into https://www.domain.com/

I want to add the trailing slashes at the end of the domain name. 我想在域名的末尾添加斜杠。

For example, redirect from https://www.eatonline.dk to https://www.eatonline.dk/ 例如,从https://www.eatonline.dk重定向到https://www.eatonline.dk/

You can keep you dynamically changing URL in an variable and can add the slash at the end 您可以在变量中动态更改URL,并可以在末尾添加斜杠

For example : var URL = "www.eatonline.dk" (You can assign the value as dynamically here ). 例如:var URL =“ www.eatonline.dk”(您可以在此处动态分配值)。 url = url + "/"; url = url +“ /”; Now the URL variable will have the value as "www.eatonline.dk/" which is still an link. 现在,URL变量的值为“ www.eatonline.dk/”,它仍然是一个链接。

Try this to add trailing slash to all urls 尝试此操作将斜杠添加到所有网址

RewriteEngine On
RewriteCond %{HTTPS} !off
RewriteRule (.*) https://%{HTTP_HOST}/$1$2/ [L,R=301]

it will redirect: 它将重定向:

https:// www.eatonline.dk > https:// www.eatonline.dk/ https:// www.eatonline.dk> https:// www.eatonline.dk/

and also 并且

https:// www.eatonline.dk/test > https:// www.eatonline.dk/test/ https:// www.eatonline.dk/test> https:// www.eatonline.dk/test/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM