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.

Background

i have a website running on wordpress and all its files are located in public_html of my host. Within it i created a sub domain "phantomomaga" and redirected an other domain to that sub domain to make it "www.phantomomaga.tk" instead of "phantomomaga.my-domain.com" for this i added some code to the .htaccess of my public_html as told here to make it like follow

Code

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

#Fix missing trailing slash character on folders.
RewriteRule ^([^.?]+[^.?/])$ $1/ [R,L]

#www.phantomomaga.tk and phantomomaga.tk will map to the folder {root}/phantomomaga/
RewriteCond %{HTTP:Host} ^(?:www\.)?phantomomaga\.tk$
RewriteCond %{REQUEST_URI} !^/phantomomaga/
RewriteRule ^(.*) phantomomaga/$1 [NC,L,NS]

Problem

Due to this edit i was able to achieve what i wanted but for some reason not known to me now the permalink of my subdomain is not working and i keep getting not found errors from my wordpress install that is in my root folder and if i remove

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress 

from the .htaccess the sub domain works perfectly but the root one messes up so i think the problem is with the .htaccess of either of root or sub domain and i cant figure out the solution even after i googled it so please help.

share|improve this question
    
First of all, you only need to turn the RewriteEngine on once, not twice. Also, so you changed the domain within the .htaccess but what about via the WordPress admin area? Does the database still have the old domain? –  Kevin Langley Jr. Nov 4 '11 at 14:21
    
you got the wrong idea i have two separate wp blogs one in root/ the other in root/phantomomaga and the root/phantomomaga is given a separate domain b the code i wrote above and let me correct that RewriteEngine and see how it works –  phantom.omaga Nov 4 '11 at 14:25
    
@Kevin Langley Jr. i removed the second RewriteEngine on but still no luck –  phantom.omaga Nov 4 '11 at 14:30
    
That now makes me ask the question, why don't you have your domain for the second route directly to that internal folder instead of the root of the first one and redirect from there? –  Kevin Langley Jr. Nov 4 '11 at 14:38
    
don't know how do that i tried doing that through the cPanel of my site but could not find it any where –  phantom.omaga Nov 4 '11 at 14:46
show 2 more comments

2 Answers

up vote 0 down vote accepted

i finny found the solution my self and i am now posting it here so that others can benefit from it

this i relapsed the whole code of my .htaccess with the following and it worked

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# ---------------------------------------
# BEGIN Domain to folder mapping

# pointing phantomomaga.tk to phantomomaga
ReWriteCond %{HTTP_HOST} phantomomaga.tk
ReWriteCond %{REQUEST_URI} !phantomomaga/
ReWriteRule ^(.*)$ phantomomaga/$1 [L]

# END Domain to folder mapping
# ---------------------------------------

# ---------------------------------------
# BEGIN WordPress

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress
# ---------------------------------------

# ---------------------------------------
# BEGIN htaccess pretection

<Files .htaccess>
order allow,deny
deny from all
</Files>

# END htaccess pretection
# ---------------------------------------

</IfModule> 

you can do so with multiple domains like follow

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# ---------------------------------------
# BEGIN Domain to folder mapping

# pointing domain_1.com to folder_1
ReWriteCond %{HTTP_HOST} domain_1.com
ReWriteCond %{REQUEST_URI} !folder_1/
ReWriteRule ^(.*)$ folder_1/$1 [L]

# pointing domain_2.com to folder_2
ReWriteCond %{HTTP_HOST} domain_2.com
ReWriteCond %{REQUEST_URI} !folder_2/
ReWriteRule ^(.*)$ folder_2/$1 [L]

# END Domain to folder mapping
# ---------------------------------------

# ---------------------------------------
# BEGIN WordPress

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress
# ---------------------------------------

# ---------------------------------------
# BEGIN htaccess pretection

<Files .htaccess>
order allow,deny
deny from all
</Files>

# END htaccess pretection
# ---------------------------------------

</IfModule> 

Source=http://wordpress.org/support/topic/success-mapping-multiple-domains-to-different-folders-with-htaccess?replies=1#post-593544

share|improve this answer
add comment

You need a vhost for the subdomain that redirects to public_html/sub_domain_folder instead of trying to redirect with .htaccess. You can then do a www redirect in public_html/sub_domain_folder/.htaccess.

There should be some option in cpanel when creating the subdomain do specify which folder it directs to if you don't have direct access to your vhost.

share|improve this answer
    
nope cant find it i am using hosting24 and there is nothing in it as you said and that is the main reason why i am asking how to successfully do this with my .htaccess and i have almost done so the only thing is now it seems to be having some kind of conflict with the wordpress permalink and to solve that i am asking this very question pal :P –  phantom.omaga Nov 4 '11 at 18:06
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.