homepage Welcome to WebmasterWorld Guest from 54.198.224.121
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
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




msg:3860737
 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




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

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

Jim

brnm98105




msg:3860982
 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




msg:3861009
 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




msg:3861299
 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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved