Forums

.htaccess file issue with a wordpress blog that is in a sub folder (7 posts)

  1. pieyum
    Member
    Posted 9 months ago #

    Hello, I'm having a very strange problem. I have a WordPress blog set up in a subfolder (root/blog/) and have a .htaccess file in the root folder that is removing the "www" from my domain. So if you go to http://www.domain.com it will switch it to domain.com. Now when I access the wordpress blog with domain.com/blog/ it works just fine. But if I access it with http://www.domain/blob/ it redirects to my cgi folder for some reason. I've played around with .htaccess files but no luck. Can someone help? Note: My root site isn't a blog. It's a basic html site.

    Here's the content of my files:

    Root .htaccess:
    ================

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^domain\.com$
    RewriteRule (.*) http://domain.com/$1 [R=301,L]
    </IfModule>

    Root/blog .htaccess:
    ================

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /blog/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blog/index.php [L]
    </IfModule>
    # END WordPress
  2. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 9 months ago #

    Is it http://www.domain.com/blog or http://www.domain.com/anything that's redirecting to CGI?

    In your WP install did you set your site as domain.com/blog or http://www.domain.com/blog?

  3. pieyum
    Member
    Posted 9 months ago #

    http://www.domain.com/blog is the problematic one. The sub-folder is called "blog".

    http://domain.com/blog works just fine.

  4. pieyum
    Member
    Posted 9 months ago #

    Oh and here's more info. I get redirected to:
    http://domain.com/cgi-bin/php/blog/index.php

    And get the following error:
    Warning: Unexpected character in input: '' (ASCII=15) state=1 in /usr/bin/php5-cgi on line 6779

    Parse error: syntax error, unexpected T_STRING in /usr/bin/php5-cgi on line 6779

    It should be http://domain.com/blog/index.php

  5. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 9 months ago #

    Try putting

    <IfModule mod_rewrite.c>
    RewriteEngine On
    Options +FollowSymLinks
    RewriteCond %{HTTP_HOST} !^domain\.com$
    RewriteRule (.*) http://domain.com/$1 [R=301,L]
    </IfModule>

    or

    <IfModule mod_rewrite.c>
    RewriteEngine On
    Options +FollowSymLinks
    RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
    RewriteRule (.*) http://domain.com/$1 [R=301,L]
    </IfModule>
  6. pieyum
    Member
    Posted 9 months ago #

    Does this go in the root folder .htaccess or the blog subfolder one?

  7. pieyum
    Member
    Posted 9 months ago #

    I tried updating the root .htaccess file with what you recommended and still have the same issue.

Reply

You must log in to post.

About this Topic