Forum Moderators: phranque
this is my .htaccess code
Options All -Indexes
ErrorDocument 404 /404.php
FileETag MTime Size
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^sitemap\.xml$ feed.php?output_type=sitemap [L]
RewriteRule ^(.*)(\.html¦\.htm)$ index.php [L]
RewriteRule ^(.*)(\.rss¦\.atom¦\.txt)$ feed.php [L]
RewriteRule ^([^.]*)/?$ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
</IfModule>
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType image/gif "access plus 1 months"
ExpiresByType image/jpeg "access plus 1 months"
ExpiresByType image/png "access plus 1 months"
</IfModule>
[edited by: jdMorgan at 9:16 pm (utc) on Oct. 23, 2008]
[edit reason] Corrected code post formatting only. [/edit]
Are these subdomains new?
Or did your subdomains stop working after you added this code?
Are the subdomains defined in your DNS zone file?
How did you 'create' the filespace for the subdomains - Did you use a control panel, or did you add code to do it)?
There are many ways to create and access subdomains, so we need more information.
Jim
example.com - main domain
www.example.com - www subdomain of main domain
abc.example.com - new subdomain
def.example.com - new subdomain
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
There are multiple problems here, and if you cannot tell us what this code is supposed to do, then we cannot help you fix all of the problems. Are you running WordPress, by any chance?
Jim
All I know is that RewriteConds must be followed by a RewriteRule, and there is no RewriteRule following those two lines in your file. So that is an error.
I suggest the following changes to your file:
Options All -Indexes
ErrorDocument 404 /404.php
FileETag MTime Size
#
RewriteEngine on
#
# Redirect non-canonical hostname requests to canonical hostname
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC,OR]
RewriteCond %{HTTP_HOST} example\.com(\.¦\.?:[0-9]+)$ [NC]
RewriteRule (.*) http://example.com/$1 [R=301,L]
#
# Skip the next four rules if the requested hostname is not exactly "example.com" or blank
RewriteCond %{HTTP_HOST} !^(example\.com)?$
RewriteRule .* - [S=4]
#
RewriteRule ^sitemap\.xml$ feed.php?output_type=sitemap [L]
#
RewriteRule ^([^.]+\.)+html?$ index.php [L]
#
RewriteRule ^([^.]+\.)+(rss¦atom¦txt)$ feed.php [L]
#
RewriteRule ^([^.]*)/?$ index.php [L]
#
# Set expires response headers for images
ExpiresActive on
ExpiresByType image/gif "access plus 1 months"
ExpiresByType image/jpeg "access plus 1 months"
ExpiresByType image/png "access plus 1 months"
The new "skip" rule causes the following four rules to be by-passed if the requested hostname (domain) is *not* your main domain. So those four rules will no longer be applied to any subdomains.
Jim
# Redirect non-canonical subdomain hostname requests to canonical hostname
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com(\.¦\.?:[0-9]+)$ [NC]
RewriteRule (.*) http://%1.example.com/$1 [R=301,L]
Options -Indexes DirectoryIndex <index-filename.extension> The "usual" configuration is to use Options -Indexes, but provide and declare an index file. In this case, the index file should be served, even with directory indexes disabled.
The purpose of Options -Indexes is to prevent visitors from seeing an index (a file listing) of all files in a directory when that directory does not have a defined index (HTML) page. This can be a security problem.
Jim