Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I understand little about regular expressions, but I need to figure one out to use with the Redirection plugin which supports redirects with regular expressions. http://urbangiraffe.com/plugins/redirection/

What I need to do is redirect all urls in /oldsite/ to the domain root. That means any page in /oldsite/ like /oldsite/this-is-my-page.html, /oldsite/this-is-my-page-too.html, etc., needs to go to root via a regular expression.

I can't get a 301 redirect rule to work in .htaccess for some reason; there may be a restriction at the host, so I need to use this plugin.

It needs to be a regular expression in the format that the plugin understands. Some examples are in the docs for the plugin at that link above. The first field for a new redirection in the plugin takes the regular expression; the second field is the target URL.

This doesn't work:

Source: /oldsite/*
Target: http://mydomain.com

Nor does this:

Source: ^oldsite/(.*)
Target: http://mydomain.com
share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

Got it to work with this:

Source: /oldsite/(.*)
Target:  http://mydomain.com
share|improve this answer
add comment

I modified it to redirect to a different URL but maintain the requested page:

Source: /(.*)
Target: http://mysite.com/$1
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.