homepage Welcome to WebmasterWorld Guest from 54.242.140.11
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Need help on rewrite code
brnm98105

5+ Year Member



 
Msg#: 3860735 posted 1:58 am on Mar 2, 2009 (gmt 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.

 

jdMorgan

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



 
Msg#: 3860735 posted 1:57 pm on Mar 2, 2009 (gmt 0)

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

Jim

brnm98105

5+ Year Member



 
Msg#: 3860735 posted 3:05 pm on Mar 2, 2009 (gmt 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?

jdMorgan

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



 
Msg#: 3860735 posted 3:24 pm on Mar 2, 2009 (gmt 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

brnm98105

5+ Year Member



 
Msg#: 3860735 posted 9:57 pm on Mar 2, 2009 (gmt 0)

Thanks JD Ill check it out!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved