Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • Tim, that is a good clear example.. thanks! ..but I do not need to serve up a different directory, conditionally.. but rather just a different defaultIndex, IP-conditionally. At first (noob) glance at your sample code.. if I used that.. it would affect even traffic that was directed to other (sub)?domains on our site. I need a custom/dev IP-induced defaultIndex for only a specific subdomain. Commented Jul 27, 2012 at 17:43
  • @govinda I added an example for the situation you have outlined. If you need the URI check to only check a subfolder, change ^index\.html to ^yoursubfolder/index\.html Commented Jul 27, 2012 at 17:52
  • Tim, as per your suggestion, I just tried this: RewriteCond %{REMOTE_ADDR} ^555\.666\.777\.888$ RewriteCond %{REQUEST_URI} ^dlindex1\.html RewriteRule .* /dlindex2.html ...but it seems to have no effect at all. IOW, it seems that the ` ServerName dl.domain.org DirectoryIndex dlindex1.html` from httpd.conf is the only thing Apache is listening to here. Is it because %{REQUEST_URI} did NOT contain 'dlindex1.html' before that DirectoryIndex kicked in? ; you see I am trying to effectively override the DirectoryIndex dlindex1.html from httpd.conf. Commented Jul 27, 2012 at 20:02
  • Where are you placing these directives? Also, that remote address, does not seem to be real, so it would never match for you, defaulting to DirectoryIndex you specified previously (in this case, in httpd.conf) (If you are censoring the IP address forgive me!) Commented Jul 27, 2012 at 20:40
  • 1
    @govinda I suggest trying the example in a new .htaccess files. Also note I caught a mistake, my regex for REQUEST_URI had a leading carrot ^, I removed that and placed a $ at the end. You could also remove the REQUEST_URI restriction completely, to debug it. Commented Jul 28, 2012 at 15:54