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 have Wordpress (v3.2.1) set up at domain.org.nz/wordpress with a number of pages set up as domain.org.nz/wordpress/services/example. I want to set up a subdomain, example.domain.org.nz to point to domain.org.nz/wordpress/services/example. When the subdomain is entered into the address bar, it (preferably) should stay as the subdomain (not a redirect). If there are any child pages of /example, the URL needs to appear as example.domain.org.nz/child. I have access to all Wordpress files, .htaccess, DNS settings etc but as I'm on a shared server, I don't have access to the httpd.conf

I know this is a similar question to Multiple Domain Names - One WP Install (non-Multisite) - Default Each Domain name to Category Archive Can I use the same method? If so what needs to be changed for that to work in my instance?

After almost a week of butting my head against this problem, any help is very much appreciated!!

Current .htaccess:

    # BEGIN WordPress  
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /wordpress/
    RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.org\.nz$
    RewriteRule ^(.*) http://domain.org.nz/wordpress/services/%1
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /wordpress/index.php [L]
    </IfModule>

    # END WordPress
share|improve this question
    
did you find as solutionfor this? –  Steven Nov 29 '11 at 17:02
add comment

2 Answers

Either try placing an index.php file inside your subdomain folder with the following code:

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Status: 301 Moved Permanently");
header("Location: http://www.my-domain.com/my-permalink/");
?>

or use cPanel to setup/redirect the subdomain to any address you want.

share|improve this answer
add comment

First you have to configure your server (DNS + Apache) to let the subdomains point to the main site domain. Usually this does not require direct access to httpd.conf but can be configured in the hosting control panel (e.g. if using cPanel you may simply add subdomains (or a wildcard) pointing to the root folder of the site).

Then add a Rewrite Rule to your .htaccess in site's root, before the Wordpress rules (not tested):

RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.org\.nz$
RewriteRule ^(.*) http://domain.org.nz/wordpress/services/%1
share|improve this answer
    
Hi marcochiesi, thanks for your reply. The code above gets me much further than I have before but results in: Found The document has moved here. Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request. –  Thorned Rose Nov 23 '11 at 2:14
    
It looks like I forgot a pair of ( ) in my previous answer. I edited it, please try again. If still not working try to post your .htaccess content. –  marcochiesi Nov 23 '11 at 9:35
    
Unfortunately I still get the same 302 error as before :/ I've added the .htaccess (with the code you've given me) in the original question above. –  Thorned Rose Nov 24 '11 at 4:29
    
Try to change your RewriteRule as follows: RewriteRule ^(.*) http://domain.org.nz/wordpress/services/%1/ [L,P] –  marcochiesi Nov 24 '11 at 20:53
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.