我似乎不太喜欢这个正则表达式:
目前,我有:
https://example.com/forums/(共1000页)
我需要转到
https://www.example.com/(共1000页)
此外,如果进入非SSL协议,则需要移至SSL协议。全部通过301。再举一个例子:
http://example.com/forums/somepage.html转到https://www.example.com/somepage.html
和
https://example.com/forums/folder/folder2/anything转到https://www.example.com/folder/folder2/anything
感谢您的帮助。
答案 0 :(得分:0)
这将匹配您所有请求的路线(良好或不理想),并将其重新路由至您想要的良好路线。根据您的正则表达式解析器,您可能需要在其中添加一些转义符(\
)。
s#http(s)?://(www.)?example.com/(forums/)?#https://www.example.com/#g
http -- match http
(s)? -- match with or without the s
:// -- match ://
(www.)? -- match with or without www.
example.com/ -- match example.com/
(forums/)? -- match with or without forums/