Welcome to WebmasterWorld Guest from 54.226.27.104

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Need help on rewrite code

     

brnm98105

1:58 am on Mar 2, 2009 (gmt 0)

5+ Year Member



Here is what my code looks like

RewriteEngine on
rewritecond %{http_host} ^mydomain,com [nc]
rewriterule ^(.*)$ [www(dot...] )mydomain,com/$1 [r=301,nc]

This works fine except for I need to add to it so when index.html is entered I want it to go to http:// www . mydomain . com/

Any help would be appreciated.

jdMorgan

1:57 pm on Mar 2, 2009 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Please see this concurrent thread: [webmasterworld.com...]

Jim

brnm98105

3:05 pm on Mar 2, 2009 (gmt 0)

5+ Year Member



Thanks that was helpful

I almost have it

This works

RewriteEngine on
rewritecond %{http_host} ^mydomain.com [nc]
rewriterule ^(.*)$ [mydomain.com...] [r=301,nc]

But this doesnt

RewriteEngine on
rewritecond %{http_host} ^mydomain.com [nc]
rewriterule ^(.*)$ [mydomain.com...] [r=301,nc]
rewritecond $1 ^index.html [nc]
rewriterule ^(.*)$ [mydomain.com$1...] [r=301, L]

Any ideas I can make these live in harmony?

jdMorgan

3:24 pm on Mar 2, 2009 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Look at the threads turned up by the search link in that thread, and pay particular attention to the phrase "direct client request" in the relevant threads.

Also, do not feel free to deviate in format or casing from the mod_rewrite directive and variable documentation; Doing so may cause problems on some hosts, and it is just not worth the risk.

You will also need to reverse your rules to avoid a double redirect if index.html is requested from a non-canonical domain, and if this code goes into .htaccess, there is a slash missing in your substitution URL.

Jim

brnm98105

9:57 pm on Mar 2, 2009 (gmt 0)

5+ Year Member



Thanks JD Ill check it out!
 

Featured Threads

Hot Threads This Week

Hot Threads This Month