I’m trying to redirect a site with the following url structure:
https://example.com/2021/about
to
https://2021.example.com/#about
https://example.com/2021/visit
to
https://2021.example.com/#visit
how can i do this?
i tried adding this to the /about directory in the original domain:
RewriteEngine on
RewriteBase /
RewriteRule (.*) https://2021.example.com/#about [R=301,NE, L]
but what i got after the redirect was
https://2021.example.com/#about2021/about
which is not right. any help is appreciated
[EDIT] i only want to apply this to some folders, like /2021/about and 2021/visit
2
Answers
Could you please try following, written based on your shown samples. Please make sure to clear your browser cache before testing your URLs. Following will only be applied to
2021/about
OR2021/visit
uris.You may use this redirect rule:
Make sure this is your topmost rule in .htaccess and you clear your browser cache before testing this new rule.