1

I;ve got a doman alias setup for one of my Wordpress sites and i'm trying to forward that particular domain to a page.

The 2 domains are -

www.alias.com www.actual.com When people use the www.alias.com domain i want them to be forwarded to www.alias.com/content/

I've tried several things with the htaccess file but i think Worpdress may be ignoring the redirects or i've got it completely wrong!

ie

Redirect 301 www.alias.com http://www.alias.com/content/

# and
RewriteCond %{HTTP_HOST} ^www.alias.com
RewriteRule (.*)$ http://www.alias.com/content/ [R=301,L]

best, Dc

2 Answers 2

2

First off -- does your server allow overrides in .htaccess files? If not, you need to get that turned on. My server has AllowOverride All set in its config file, which then allows my .htaccess rules to function.

Does alias.com point to the same directory as actual.com? If not, then you need to put a .htaccess file in the alias.com root.

Also, if I understand your requirements correctly, the .htaccess file for alias.com needs to contain this:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.alias.com$ [NC]
RewriteRule ^(.*)$ http://www.actual.com/content/ [R=301,L]

References

Apache's Config File & URL Rewriting docs

I also have a mod_rewrite from http://www.ilovejackdaniels.com/ but that site seems to be down now.

5
  • Hey Pat - set AllowOverride All but still nothing happens. Both domains point to the same directory. Code im using is; RewriteEngine On RewriteCond %{HTTP_HOST} ^www.indy8.com$ [NC] RewriteRule ^(.*)$ indy8.com/content [R=301,L]. I want to keep the alias domain in the address bar for this page if possible.
    – v3nt
    Commented May 21, 2013 at 15:56
  • Did you restart your web server after setting AllowOverride All? Also, I think the 301 redirection will change the browser's address bar to reflect the new URL, but I could be mistaken.
    – Pat J
    Commented May 21, 2013 at 16:04
  • yeh i did. Can't seem to find a quick way of testing if AllowOverride is working. Feels like this should be pretty straightforward!
    – v3nt
    Commented May 21, 2013 at 16:10
  • ok - i'm an idiot. Just moved the site to a new server but ftp was pointing to old server! Used this in the end - RewriteCond %{HTTP_HOST} ^www.indy8.com$ RewriteRule (.*)$ indy8.com/content/$1 [R=301,L]. Thanks for your help!
    – v3nt
    Commented May 21, 2013 at 16:25
  • I can't count the number of times I've made a mistake like that... Glad it's working.
    – Pat J
    Commented May 21, 2013 at 16:30
0

Since this is a WordPress question and still on the first position in Google, I'll add a not-so-technical solution for the scenario:

Today there are redirect-plugins that you can use - no need to modify an htaccess file or other server configuration.

WPMU DEV SmartCrawl

I use SmartCrawl for those cases, like this:

smartcrawl pro

Related Links

Note: I'm not affiliated with WPMU DEV, I just like their products.

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.