Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a bunch of rewrite rules to redirect visits from domainX to domainY, however now I want show an index.html page when people visit domainX, but I still want all the other rewrite rules to apply.

I read on stackoverflow that I can just add something like this at the top:

RewriteRule  ^index.html  -  [L]

However it's not working. I'm not sure why. Any suggestions?

NOTE: Current rewrite config file is available here.

share|improve this question
2  
It would help if you could post your current rewrite rules. Probably this is best solved with a RewriteCond, but it's hard to say what fits your configuration best if we don't know how it currently looks. –  Jenny D Apr 3 '13 at 10:00
    
i have a TON of rules. >650 lines (redirecting all kinds of shop products. does it matter what comes after this? if this is at the top shouldn't it work? I'll post a few, but worry moderators will ban me for trying to advertise. –  Max Hodges Apr 3 '13 at 10:03
    
No, that's enough! Thanks! –  Jenny D Apr 3 '13 at 10:09

1 Answer 1

This would be my solution:

RewriteCond %{HTTP_HOST} ^(.*)whiterabbitpress.com$ [NC]
RewriteCond %{REQUEST_URI} !^/index.html$ [NC]
RewriteRule ^new-arrivals.html$ http://shop.whiterabbitjapan.com/japanese-language/new-arrivals.html [L,R=301]
[...]

This means that all the following rules will only be used when the hostname is *.whiterabbitpress.com, and the path is not /index.html.

Kudos to you for posting the actual config instead of munging it, it really makes it a great deal easier to help!

share|improve this answer
    
do I need to insert that condition about /index.html before after every RewriteCond in my script? there are many of them further down. see here pastebin.com/mA8qNW8t –  Max Hodges Apr 3 '13 at 10:19
    
You'd only need that where there's a RewriteCond that would otherwise match, so from a quick glance I don't see that it should be necessary, since there's usually no query string used for index.html. –  Jenny D Apr 3 '13 at 10:37
    
hum but is it not working nonetheless D: –  Max Hodges Apr 3 '13 at 10:43
1  
I would suggest you enable rewritelog. Your original suggestion should normally work. You need to find out why it isn't applied. Are these rewriterules in a .htaccess file, or in the httpd.conf (or an included file)? –  Krist van Besien Apr 3 '13 at 13:33
1  
btw, lookin at your rules they could probably be massively simplyfied by using a rewritemap... –  Krist van Besien Apr 3 '13 at 13:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.