megamiska Merchant Tól től Slovenia Tagság okt. 2023 óta megamiska 21 márc. 2024 15:34 About redirects...Create a moved (HTTP 301) ruleMatch: ^https?://([^/]*)/oldpage(\?|$)Redirect: https://$1/newpageHow can I create rule that will redirect all urls start with:https://mydomain.com/kategorija-izdelka/https://mydomain.com/izdelek/For example:https://mydomain.com/kategorija-izdelka/category-1https://mydomain.com/kategorija-izdelka/category-2/subcategoryto:https://mydomain.com/Because I see in log that if url is not exactly https://mydomain.com/kategorija-izdelka, get redirected to https://mydomain.com/subcategory instead just to to https://mydomain.com.
tim Founder Tól től Sweden Tagság máj. 2013 óta tim 22 márc. 2024 17:28 Short answer:^https://www\.mydomain\.com/kategorija-izdelka/.*^ match string beginning\. matches an actual dot. match any character* continouslySome explainations:To match urls starting with. ^https://mydomain\.com/kategorija-izdelka/To match both http and https, make s optional by succeeding it by a ?^https?://mydomain\.com/kategorija-izdelka/To match both or without www., group it with a paranthesis and succeed it by a ? to make it optional:^https?://(www\.)?mydomain\.com/kategorija-izdelka/(This group is captured and retrieved by $1 if you need it in your redirect url)To match any domain, [^/] means anything that is not a slash / and * means continously:^https?://([^/]*)/kategorija-izdelka/To match an exact url, and nothing else preceeding or following.^https://mydomain\.com/kategorija-izdelka/$..and to make the last slash optional^https://mydomain\.com/kategorija-izdelka/?$To match an exact url with optional query parameters following. (\?|$) means match a question mark or the end of string.^https://mydomain\.com/kategorija-izdelka/?(\?|$)Use this online tool for toying with regex:https://regex101.com/^https://mydomain\.com/kategorija-izdelka/ will turn https://mydomain\.com/kategorija-izdelka/remainings into https://redirectdomain\.com/remainings.While ^https://mydomain\.com/kategorija-izdelka/.*$ will turn https://mydomain\.com/kategorija-izdelka/remainings into https://redirectdomain\.com/.
megamiska Merchant Tól től Slovenia Tagság okt. 2023 óta megamiska 23 márc. 2024 18:14 @tim Thank you very much for detailed and easy explanation!