WordPress.org

Forums

[resolved] need help in fixing my .htaccess to remove wordpress permalink problems (4 posts)

  1. phantom.omaga
    Member
    Posted 3 years ago #

    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.

  2. phantom.omaga
    Member
    Posted 3 years ago #

    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

  3. JDHayes
    Member
    Posted 2 years ago #

    Thank you for this information. I am completely new to WordPress and looks like I am having the same permalink issues you were. Can I ask which directory you specifically put the .htaccess file in? I have a standard Go-Daddy installation and I have not customized the file / directory structure.

    Thanks

    John

  4. phantom.omaga
    Member
    Posted 2 years ago #

    @JDHayes in the main public_html folder (or root folder) i have also told so in the original problem specified above.

Topic Closed

This topic has been closed to new replies.

About this Topic