.htaccess experts, I summon thee! A challenge awaits!

Merlin

Expert Member
Joined
Jan 18, 2006
Messages
2,804
Reaction score
325
Location
Cape Town, South Africa
Ola,

I have one of the most complex .htaccess files I've personally encountered. Considering I'm only an amateur tinkerer with this stuff, that's not always a good recipe. :D

It's giving me hassles at the moment and I could surely do with some help, please.

Code:
## Domain exclusions ("(www.)example.co.za" and blank)
# Parked bbb.za.org Redirect exclusion
RewriteCond %{HTTP_HOST} ^(www\.)?bbb\.za\.org
RewriteRule (.*) http://blog.aaa.com/sub1/sub2/$1 [R=301,L]

# Other Addon/Parked exclusions
RewriteCond %{HTTP_HOST} !^((www\.)?ccc\.co\.za\.?(:[0-9]+)?)?$
RewriteCond %{HTTP_HOST} !^((www\.)?ddd\.za\.net\.?(:[0-9]+)?)?$
RewriteCond %{HTTP_HOST} !^((www\.)?eee\.za\.org\.?(:[0-9]+)?)?$

# Directory exclusions
RewriteCond %{REQUEST_URI} !^/(_attachments)/

# File exclusions
RewriteCond $1 !^(page\.php|sitemap\.xml|sitemap\.xml\.gz|robots\.txt|googlexxxxxxxxxx\.html)$

# All other requests to...
RewriteRule ^(.*)$ http://blog.aaa.com/$1 [R=301,L]

# Sitemap redirection
Redirect 301 /sitemap.xml [url]http://blog.aaa.com/sitemap.xml[/url]

# Redirect if subfolder index is requested (Signature/s, etc.)
RewriteRule ^_attachments/?$ [url]http://blog.aaa.com/[/url] [R=301,L]

# Redirect if non-existent file in subfolder is requested
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^_attachments/(.+)$ http://blog.aaa.com/$1 [R=301,L]

I'm hoping you're all going to tell me that that horror is actually not that bad, but I suspect I'm about to be crucified by you lot. :D

As you might imagine, it's not working correctly...

When you request aaa.com/sitemap.xml it is not pulling it from blog.aaa.com/sitemap.xml and I am not sure whether ^ this is the problem or if it has something to do with needing to free up that file in the blog folder's .htacess file.

Secondly, I have another subfolder of aaa.com that is getting forwarded to either blog.aaa.com or showing up a 301 error no matter what I try. It is a standalone subdomain.

Please take pity on me. Haha. Can you help, please?

Thank you.
 
Top
Sign up to the MyBroadband newsletter
X