Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite trouble

.htaccess file using mod_rewrite works on two domains but not another.

         

dgerler

1:14 pm on Dec 30, 2003 (gmt 0)

10+ Year Member



Good Morning,

First, I would like to thank the many people that have posted info and links about mod_rewrite in these forums. I have spent numberous hours already looking through the forums.

Due to the great info, I was able to write this code:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^/$ /catalog/
RewriteRule ^index.htm /catalog/

It works great on two of my domains. It redirects the docroot to the catalog directory just fine as in:

www.mydomain.com shows the www.mydomain.com/catalog/default.php page.

My problem is with the third domain. When I use www.mythirddomain.com I get the index of the directory because there isn't an index.htm in the docroot.

The catalog directory is identical to the other two domains and the domains are all virtual hosts on the same server. If I use www.mythirddomain.com/index.htm, it redirects to the catalog directory correctly.

Does anyone have any ideas where or what I can check from here? If someone needs to see the directory listing (maybe a file is causing the problem), stickymail me for the url.

Lastly, any help will be appreciated.

Longhaired Genius

1:33 pm on Dec 30, 2003 (gmt 0)

10+ Year Member



Try: RewriteRule ^$ /catalog/ as the last rule (no guarantees, just an idea)

Also, it's usually best to put a [L] (for last) at the end of each rule so that if you get a match no further rewriting is attempted.

dgerler

2:08 pm on Dec 30, 2003 (gmt 0)

10+ Year Member



Longhaired Genius,
You have your username for a reason, I see. Your suggestion worked like a champ. I swear that I tried everything else besides that in the several hours that I worked on this.

It still allows specific doc requests through, too.
i.e. www.mydomain.com/tools.htm shows the tools.htm from the docroot.

Thanks a Million! I can see that I have found a goldmine here.

Dave

jdMorgan

4:41 pm on Dec 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Dave,

Welcome to WebmasterWorld [webmasterworld.com]!

Also, you could add


Options -Indexes

and

DirectoryIndex default.php

near the top of the appropriate .htaccess file(s), in order to tell the server to return "default.php" whenever "/" is requested. See Apache mod_dir and Options in Apache Core documentation [httpd.apache.org] for details.

Jim

dgerler

7:47 pm on Dec 30, 2003 (gmt 0)

10+ Year Member



Thanks, Jim. I did know about the -Index but haven't gotten around to it yet.. (too many Irons)

I will add the DirectoryIndex default.php to the catalog directory.

It's good to be here. I have been looking for a resource like this for a long time. I just needed the right search phrase to bring me here.