0

I have some bad links pointing at abc.com. Wordpress automatically redirects abc.com to www.abc.com.

I need to redirect abc.com to a holding page... let's say www.abc.com/holding.html.

What is the best way to do this?

I've tried a bunch of things but none of them work :(

2
  • Is it WordPress that's redirecting abc.com to www.abc.com, or is it your hosting provider?
    – Pat J
    Jul 23, 2013 at 15:01
  • Hi Pat, i believe WP automatically redirects from one to the other since v2.4
    – Michael
    Jul 24, 2013 at 21:22

1 Answer 1

0

If you are hosting on a LAMP environment. You can put this redirect in .htaccess file. RedirectRule must be placed before the WordPress generate rules. So that, your rule get executed before WordPress take it through. RewriteRule will look something like this

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase / # if WP installed in a folder use /folder_name
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule . /holding.html [L] # to redirect all 404 pages
RewriteRule bad_link\.html /holding.html [L] # to redirect selected 404 page
</IfModule>

Note: Make sure it is placed before the WordPress generate Rewrites. Otherwise, it wont be work

Edit: To redirect domain.com to domain.com/holding.html replace 7th line with following

RewriteRule ^$ /holding.html [L] # to domain.com to holding.html page
8
  • Thank you so much! Not sure what is meant by 'before the wordpress generate rewrites exactly... i inputted it above what i think you meant, but it didnt work. Here's a copy of my very short .htaccess file. I added your code in lines 8-17. What do you think? Thanks!!
    – Michael
    Jul 23, 2013 at 17:26
  • 1
    couldnt paste it here so here is a link to see it: pastebin.com/YKD4KAnk
    – Michael
    Jul 23, 2013 at 17:28
  • Move it to top of the file. Do you see an internal server error or what? have you properly changed the domain name? Moreover, add "RewriteBase" too.
    – M-R
    Jul 23, 2013 at 17:29
  • No error, it just doesnt redirect from domain.com to domain.com/holding.html. I added 'RewriteBase /' and also tried deleting line 18 onwards - so my .htaccess file only contains what you advised. What do you mean by 'bad_link'?
    – Michael
    Jul 23, 2013 at 18:24
  • Updated the answer for "domain.com" specific redirect. Please check.
    – M-R
    Jul 23, 2013 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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