Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I've been at this for about an hour now and I'm not having much luck. htaccess files are quite new to me, so I'm obviously doing something very wrong.

Current htaccess content, which I need to keep:

RewriteEngine On
RewriteRule ^blog-page-([^-]*)$ ?page=$1&p=home [L]
RewriteRule ^blog-([^-]*)+? ?d=$1&p=home [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?p=$1 [L]

I need to redirect 100+ old (WordPress) URLs back directly to the domain, such as:

/some-url-as-seen-by-google/ -> www.domain.co.uk

They all follow the same pattern, for example:

/something/some-url-as-seen-by-google/
/some-url-as-seen-by-google/

I've tried all kinds of RewriteRule, RedirectMatch 301, Redirect 301 rules, but I just can't seem to get my head around it, or get it to work.

share|improve this question
1  
Are you trying to redirect them to a single page, or different versions of the URLs. –  Max Dec 13 '13 at 1:33
1  
He wants to redirect all of them to a single page -- the home page. –  Stephen Ostermiller Dec 13 '13 at 12:02

1 Answer 1

The URLs you want to redirect to the home page are all currently handled by this rewrite rule:

RewriteRule ^(.*)$ index.php?p=$1 [L]

so you have a conflict.

I use this WordPress plugin for these types of redirects: Quick Page Post Redirect Plugin. You have to specify all of the redirects individually rather than with a pattern, but with only 100, that sounds doable.

share|improve this answer
    
So if the rewrite I'm using conflict with the above rule and I'd need to create individual rewrite, would I have to create rule such as.. RewriteRule ^/some-url-here/$ www.domain.co.uk –  Alex Dec 13 '13 at 19:39
    
That sounds like a good option as well. You'd just have to make sure to put those rules after 'RewriteEngine On' but before other rules. –  Stephen Ostermiller Dec 13 '13 at 19:46
    
I'm still getting a conflict with RewriteRule ^(.*)$ index.php?p=$1 [L] when I add my own rule of RewriteRule ^/some-url-here$ www.domain.co.uk. It rewrites the url to www.domain.co.uk/p?=some-url-here. Think I'll admit defeat for now. –  Alex Dec 13 '13 at 20:09
    
Add [R=301,L] so that it redirects and doesn't trigger anymore rewrite rules. –  Stephen Ostermiller Dec 13 '13 at 20:23
    
For some reason, I couldn't get your way to work; I must have been doing it wrong somehow, but I think I have it working now but a different way. I added Redirect 301 /some-url-here www.domain.co.uk directly after Rewrite Engine On. I'm not entirely sure if it's the proper way of doing it, but it works for the time being, until I do a bit more learning :) ::Edit:: scratch that, my way doesn't work hah –  Alex Dec 13 '13 at 20:48

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.