0

I have the following .htaccess file:

DirectoryIndex index.html

Options +FollowSymLinks
RewriteEngine On

AddEncoding gzip .gz
AddEncoding gzip .gzip
<FilesMatch "\.(js.gz|js.gzip)$">
  ForceType text/javascript
</FilesMatch>
<FilesMatch "\.(css.gz|css.gzip)$">
  ForceType text/css
</FilesMatch>

#RewriteCond %{REQUEST_URI} .*/http-bind
#RewriteRule (.*) /http-bind [L]

RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_URI} !/ow_updates/index\.php
RewriteCond %{REQUEST_URI} !/ow_updates/
RewriteCond %{REQUEST_URI} !/ow_cron/run\.php
RewriteCond %{REQUEST_URI} !/index\.html
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.xml|\.feed|robots\.txt|\.raw|/[^.]*)$  [NC]
RewriteRule (.*) index.php

I want everything else in the .htaccess to work like it was: redirect all requests except those specified with ! to index.php. However, I need to load index.html the first time the site is loaded, and them keep loading index.php afterwards.

So I added the line DirectoryIndex index.html at the beginning, and then added the line RewriteCond %{REQUEST_URI} !/index\.html, hoping that when users type http://url.com, they are taken to the index.html file, from which they will go to inner pages like http://url.com/homepage which will all be requests handled by index.php.

This is not working, however. The software I am using is Oxwall. The site simply ignores the first line and keeps loading index.php no matter what. What can I do to remedy this? Thanks.

1 Answer 1

1

You can easily handle this with PHP with either the session or cookies. You can make it always redirect somebody to index.php and in index.php you can include the index.html file to show if they are visiting the first time. If you redirect them to the html file it will not work (.htaccess will get in the way), but if you include the file then it should work just fine.

1
  • Thanks; yes, this is indeed a possibility, but I'd like to avoid it because there is already a lot of cookie/session manipulation in the main site script and I'd be interfering in that logic...
    – Aditya M P
    Dec 18, 2012 at 23:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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