Welcome to WebmasterWorld Guest from 54.145.13.215

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Need help on rewrite code

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

Junior Member

5+ Year Member

joined:Sept 10, 2008
posts: 79
votes: 0


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.

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

Senior Member

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

joined:Mar 31, 2002
posts:25430
votes: 0


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

Jim

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

Junior Member

5+ Year Member

joined:Sept 10, 2008
posts: 79
votes: 0


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?

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

Senior Member

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

joined:Mar 31, 2002
posts:25430
votes: 0


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

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

Junior Member

5+ Year Member

joined:Sept 10, 2008
posts:79
votes: 0


Thanks JD Ill check it out!