WebFaction
Community site: login faq

Is there a way to set a simple redirect without having to create an app? I just want the following:

subdomain.mydomain.com

to redirect to

www.mydomain.com/folder

Many thanks

asked 03 Feb '12, 07:29

mrcevic
111
accept rate: 0%


You could add your subdomain to the same website entry in your control panel, so both would serve the same application and then, in it's .htaccess file, add something similar to:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^subdomain\.mydomain\.com$
RewriteRule (.*) http://www.mydomain.com/folder/$1
permanent link

answered 03 Feb '12, 08:18

iliasr ♦♦
2.1k14
accept rate: 35%

edited 03 Feb '12, 10:33

Thanks! I forgot to mention that I tried the .htaccess approach (I followed this) which didn't work. But I forgot to add the subdomain to my website list and make it point to the same app as the domain. Now I did both, but I still don't see the results. I've got WP running on the main domain and so I added the rewrite conditions before WP's. My .htaccess looks like:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^victor.domain.com$ 
RewriteRule (.*) http://www.domain.com/victor/$1

RewriteCond %{HTTP_HOST} ^walter.domain.com$ 
RewriteRule (.*) http://www.domain.com/walter/$1 [R=301,L]

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>95

Is it possible that the rewrite rules are interfering?

(03 Feb '12, 10:12) mrcevic

I've just tried visiting http://walter.your-domain.com/testpage and I was redirected to http://www.your-domain.com/walter/testpage, so your htaccess above seems to work for me. If you are still having any issues, maybe you should raise a support ticket, so we could give it a closer look.

(03 Feb '12, 11:26) iliasr ♦♦

that's right. Now both redirects are working. Many thanks

(03 Feb '12, 13:46) mrcevic
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×76
×76

question asked: 03 Feb '12, 07:29

question was seen: 4,586 times

last updated: 03 Feb '12, 13:46

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM