Regex 301 Redirect .htaccess file [closed]
I need to redirect ALL instances of example.com/privacy-policy
to a new domain page.
For example, redirect example.com/privacy-policy
AND example.com/subfolder/privacy-policy
This is what I have:
RedirectMatch 301 ^/privacy-policy/(.+?)(-[0-9]+)?$ https://new.example/privacy-policy/v2/
I'm not having any luck and I'm struggling with other versions of this.
What am I missing?
.htaccess url redirect
closed as off-topic by Andrejs Cainikovs, Patrick Mevzek, lucascaro, Graham, Shiladitya Nov 15 '18 at 4:51
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions on professional server- or networking-related infrastructure administration are off-topic for Stack Overflow unless they directly involve programming or programming tools. You may be able to get help on Server Fault." – Andrejs Cainikovs, Patrick Mevzek, lucascaro, Graham, Shiladitya
add a comment |
I need to redirect ALL instances of example.com/privacy-policy
to a new domain page.
For example, redirect example.com/privacy-policy
AND example.com/subfolder/privacy-policy
This is what I have:
RedirectMatch 301 ^/privacy-policy/(.+?)(-[0-9]+)?$ https://new.example/privacy-policy/v2/
I'm not having any luck and I'm struggling with other versions of this.
What am I missing?
.htaccess url redirect
closed as off-topic by Andrejs Cainikovs, Patrick Mevzek, lucascaro, Graham, Shiladitya Nov 15 '18 at 4:51
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions on professional server- or networking-related infrastructure administration are off-topic for Stack Overflow unless they directly involve programming or programming tools. You may be able to get help on Server Fault." – Andrejs Cainikovs, Patrick Mevzek, lucascaro, Graham, Shiladitya
Try serverfault.com instead.
– Andrejs Cainikovs
Nov 14 '18 at 17:00
Redirects in.htaccess
are better suited to webmasters.stackexchange.com (not ServerFault).
– MrWhite
Nov 15 '18 at 0:27
This forum is widely used for questions on htaccess, mod_rewrite and regex hence there is nothing wrong in asking it here.
– anubhava
Nov 15 '18 at 10:42
add a comment |
I need to redirect ALL instances of example.com/privacy-policy
to a new domain page.
For example, redirect example.com/privacy-policy
AND example.com/subfolder/privacy-policy
This is what I have:
RedirectMatch 301 ^/privacy-policy/(.+?)(-[0-9]+)?$ https://new.example/privacy-policy/v2/
I'm not having any luck and I'm struggling with other versions of this.
What am I missing?
.htaccess url redirect
I need to redirect ALL instances of example.com/privacy-policy
to a new domain page.
For example, redirect example.com/privacy-policy
AND example.com/subfolder/privacy-policy
This is what I have:
RedirectMatch 301 ^/privacy-policy/(.+?)(-[0-9]+)?$ https://new.example/privacy-policy/v2/
I'm not having any luck and I'm struggling with other versions of this.
What am I missing?
.htaccess url redirect
.htaccess url redirect
edited Nov 15 '18 at 0:04
MrWhite
12.9k33161
12.9k33161
asked Nov 14 '18 at 16:59
WGMWGM
133
133
closed as off-topic by Andrejs Cainikovs, Patrick Mevzek, lucascaro, Graham, Shiladitya Nov 15 '18 at 4:51
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions on professional server- or networking-related infrastructure administration are off-topic for Stack Overflow unless they directly involve programming or programming tools. You may be able to get help on Server Fault." – Andrejs Cainikovs, Patrick Mevzek, lucascaro, Graham, Shiladitya
closed as off-topic by Andrejs Cainikovs, Patrick Mevzek, lucascaro, Graham, Shiladitya Nov 15 '18 at 4:51
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions on professional server- or networking-related infrastructure administration are off-topic for Stack Overflow unless they directly involve programming or programming tools. You may be able to get help on Server Fault." – Andrejs Cainikovs, Patrick Mevzek, lucascaro, Graham, Shiladitya
Try serverfault.com instead.
– Andrejs Cainikovs
Nov 14 '18 at 17:00
Redirects in.htaccess
are better suited to webmasters.stackexchange.com (not ServerFault).
– MrWhite
Nov 15 '18 at 0:27
This forum is widely used for questions on htaccess, mod_rewrite and regex hence there is nothing wrong in asking it here.
– anubhava
Nov 15 '18 at 10:42
add a comment |
Try serverfault.com instead.
– Andrejs Cainikovs
Nov 14 '18 at 17:00
Redirects in.htaccess
are better suited to webmasters.stackexchange.com (not ServerFault).
– MrWhite
Nov 15 '18 at 0:27
This forum is widely used for questions on htaccess, mod_rewrite and regex hence there is nothing wrong in asking it here.
– anubhava
Nov 15 '18 at 10:42
Try serverfault.com instead.
– Andrejs Cainikovs
Nov 14 '18 at 17:00
Try serverfault.com instead.
– Andrejs Cainikovs
Nov 14 '18 at 17:00
Redirects in
.htaccess
are better suited to webmasters.stackexchange.com (not ServerFault).– MrWhite
Nov 15 '18 at 0:27
Redirects in
.htaccess
are better suited to webmasters.stackexchange.com (not ServerFault).– MrWhite
Nov 15 '18 at 0:27
This forum is widely used for questions on htaccess, mod_rewrite and regex hence there is nothing wrong in asking it here.
– anubhava
Nov 15 '18 at 10:42
This forum is widely used for questions on htaccess, mod_rewrite and regex hence there is nothing wrong in asking it here.
– anubhava
Nov 15 '18 at 10:42
add a comment |
1 Answer
1
active
oldest
votes
You can use this rule with a tweak in your regex:
RedirectMatch 301 /privacy-policy(/.*)?$ https://new.example/privacy-policy/v2/
- By removing
^
from regex we are now matching/privacy-policy
anywhere in URI not just the start. - Since you don't care what comes after
/privacy-policy
, there is no reason to match anything but optional/.*
in the end. - Make sure to use a new browser for your testing.
1
Perfect! Thank you! I don't want to violate any forum rules here, but you can you briefly explain the error in my syntax vs yours? If not, thanks again!
– WGM
Nov 14 '18 at 17:10
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use this rule with a tweak in your regex:
RedirectMatch 301 /privacy-policy(/.*)?$ https://new.example/privacy-policy/v2/
- By removing
^
from regex we are now matching/privacy-policy
anywhere in URI not just the start. - Since you don't care what comes after
/privacy-policy
, there is no reason to match anything but optional/.*
in the end. - Make sure to use a new browser for your testing.
1
Perfect! Thank you! I don't want to violate any forum rules here, but you can you briefly explain the error in my syntax vs yours? If not, thanks again!
– WGM
Nov 14 '18 at 17:10
add a comment |
You can use this rule with a tweak in your regex:
RedirectMatch 301 /privacy-policy(/.*)?$ https://new.example/privacy-policy/v2/
- By removing
^
from regex we are now matching/privacy-policy
anywhere in URI not just the start. - Since you don't care what comes after
/privacy-policy
, there is no reason to match anything but optional/.*
in the end. - Make sure to use a new browser for your testing.
1
Perfect! Thank you! I don't want to violate any forum rules here, but you can you briefly explain the error in my syntax vs yours? If not, thanks again!
– WGM
Nov 14 '18 at 17:10
add a comment |
You can use this rule with a tweak in your regex:
RedirectMatch 301 /privacy-policy(/.*)?$ https://new.example/privacy-policy/v2/
- By removing
^
from regex we are now matching/privacy-policy
anywhere in URI not just the start. - Since you don't care what comes after
/privacy-policy
, there is no reason to match anything but optional/.*
in the end. - Make sure to use a new browser for your testing.
You can use this rule with a tweak in your regex:
RedirectMatch 301 /privacy-policy(/.*)?$ https://new.example/privacy-policy/v2/
- By removing
^
from regex we are now matching/privacy-policy
anywhere in URI not just the start. - Since you don't care what comes after
/privacy-policy
, there is no reason to match anything but optional/.*
in the end. - Make sure to use a new browser for your testing.
edited Nov 15 '18 at 0:07
MrWhite
12.9k33161
12.9k33161
answered Nov 14 '18 at 17:04
anubhavaanubhava
529k46329404
529k46329404
1
Perfect! Thank you! I don't want to violate any forum rules here, but you can you briefly explain the error in my syntax vs yours? If not, thanks again!
– WGM
Nov 14 '18 at 17:10
add a comment |
1
Perfect! Thank you! I don't want to violate any forum rules here, but you can you briefly explain the error in my syntax vs yours? If not, thanks again!
– WGM
Nov 14 '18 at 17:10
1
1
Perfect! Thank you! I don't want to violate any forum rules here, but you can you briefly explain the error in my syntax vs yours? If not, thanks again!
– WGM
Nov 14 '18 at 17:10
Perfect! Thank you! I don't want to violate any forum rules here, but you can you briefly explain the error in my syntax vs yours? If not, thanks again!
– WGM
Nov 14 '18 at 17:10
add a comment |
Try serverfault.com instead.
– Andrejs Cainikovs
Nov 14 '18 at 17:00
Redirects in
.htaccess
are better suited to webmasters.stackexchange.com (not ServerFault).– MrWhite
Nov 15 '18 at 0:27
This forum is widely used for questions on htaccess, mod_rewrite and regex hence there is nothing wrong in asking it here.
– anubhava
Nov 15 '18 at 10:42