Forum Moderators: phranque
RedirectMatch 302 ^/(?!examples\.html)examples?\.html?$ /examples.html
RedirectMatch 302 ^/example(\.htm|\.html|s\.htm)$ /examples.html
[edited by: w3dk at 1:11 am (utc) on Jan 1, 2021]
Can someone show me how to redirect the first 3 to examples.html
I know how to set up a redirect from one page to the other but not 3 to another page.
RedirectMatch 302
The use of RewriteRule to perform this task may be appropriate if there are other RewriteRule directives in the same scope. This is because, when there are Redirect and RewriteRule directives in the same scope, the RewriteRule directives will run first, regardless of the order of appearance in the configuration file.
however I assumed that I could put them all in one rule.
# Either, using a negative lookahead
RewriteRule ^/?(?!examples\.html)examples?\.html?$ /examples.html [R=301,L]
# OR, using alternation
RewriteRule ^/?example(\.htm|\.html|s\.htm)$ /examples.html [R=301,L]
RewriteRule ^/?(example\.htm|example\.html|examples\.htm)$ /examples.html [R=301,L]
RewriteRule ^/?(example)(\.htm|\.html|s\.htm)$ /$1s.html [R=301,L]
RewriteRule ^/?(?!examples\.html)examples?\.html?$ https://example.com/examples.html [R=301,L]