Forum Moderators: phranque

Message Too Old, No Replies

.htaccess redirect affecting subdomains

         

Chancha

8:31 pm on Jan 3, 2005 (gmt 0)

10+ Year Member



Hi, I am quite green to apache so please excuse me if I somehow sound like an idiot here.

Problem:

Basically, I have a site with the portal being at [example.org...] . Recently I swapped the intended index from index.html to index.php, so in order to direct old users to the currently updated page (index.php) I added this in my htaccess:

DirectoryIndex index.php index.html
Redirectpermanent /index.html [example.org...]

It is working, but;

I have other subdomains under the same directory of the root, example: [w.example.org...] or conversely [example.org...]

The index page of that subdomain is supposedly [example.org...] . If I understand it correctly, htaccess is globally affecting everything below. Therefore, every subdomains with index.html is being redirected to the root now, which I totally didn't intend.

Help... this method I mentioned is the only way I know. Been googling, no vail so far...

[edited by: jdMorgan at 9:35 pm (utc) on Jan. 3, 2005]
[edit reason] Removed specifics per TOS. [/edit]

jdMorgan

9:42 pm on Jan 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Chancha,

Welcome to WebmasterWorld!

Instead of using mod_alias, use mod_rewrite [httpd.apache.org], which can test the requested hostname and leave the URLs for non-www subdomains alone.


Options +FollowSymLinks
RewriteEngine on
# Rewrite only www.example.org/index.html and example.org/index.html to example.org/index.php
RewriteCond %{HTTP_HOST} ^(www\.)example\.org
RewriteRule ^index\.html$ http://example.org/index.php [R=301,L]

Jim

Chancha

11:49 pm on Jan 3, 2005 (gmt 0)

10+ Year Member



jdMorgan,

Wow thanks much! Looks like it is working perfectly now. Thankies dude, this place is cool and I got a lot to learn (barely understand the code you gave me...)

And also sorry for not knowing about the TOS concerning the URLs.