Forum Moderators: phranque

Message Too Old, No Replies

Help with .htaccess messing up subdomain

root .htaccess and subdomain problem

         

agentvic

5:26 am on Jan 8, 2008 (gmt 0)

10+ Year Member



I'm running Wordpress in the root and it seems that the .htaccess file is messing up accessing a subdomain of mine.

example: sub.mydomain.com will throw me a internal server error.

If I cancel out/eliminate the .htaccess then accessing the subdomain is fine. So this tells me it's something with the root .htaccess

Is there something to add to the .htaccess file so the subdomain will work properly?

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

# END WordPress
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST}!^www\. [NC]
RewriteRule ^(.*)$ [%{HTTP_HOST}...] [R,L]

Any help is appreciated. Thanks!

jdMorgan

6:11 am on Jan 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Fixing that and several other problems at various levels:

<IfModule mod_rewrite.c>
#
RewriteEngine on
#
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^[i]your-subdomain-name[/i]\. [NC]
RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [[b]R=301[/b],L]
#
# BEGIN WordPress
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
#
</IfModule>

Jim

agentvic

6:17 am on Jan 8, 2008 (gmt 0)

10+ Year Member



Thanks so much! That seems to have fixed it.

jdMorgan

2:51 pm on Jan 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here's a little speed-up tweak:

# BEGIN WordPress
RewriteCond $1 !^index\.php$
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule (.+) /index.php [L]
# END WordPress

This prevents the server from wasting a lot of time doing a 'file exists' check if the URL-path has already been rewritten to "/index.php".

Jim

swine_007

3:29 am on Jan 18, 2008 (gmt 0)

10+ Year Member



Hi Jd,

I have somewhat similar problem as agentvic but the difference is I have multiple wordpress running in different directories. And for each of the wordpress directory i would like to assign a sub-domain.

For example:

wp1.mydomain.com (points to public_html/wp1 directory)
wp2.mydomain.com (points to public_html/wp2 directory)

Any helps is greatly appreciated.

Thanks.
Shah