Web Hosting Talk







View Full Version : some .htaccess help needed


ayksolutions
12-15-2005, 10:22 PM
I need to put a site on the "under construction" splash page. The problem here is that I need to disable the rest of the site as well, so everything is pointing to index.html. Basically, if you go to www.domain.com/pagetwo it will take to you domain.com/index.html (the splash page).

I am trying to use mod_rewrite within the .htaccess file for that account. So far, I have the following:

RewriteEngine On
RewriteRule ^oldstuff\.html$ newstuff.html

(above is just an example)

Another idea I found is:

RewriteEngine on
RewriteRule ^/~(.+) http://www.domain.com/index.html$ [R,L]

I am not good with regex, but if anyone familiar with this could guide me in the right direction, I'd be thankful.

Thanks

maxymizer
12-16-2005, 05:24 AM
RewriteEngine On
RewriteBase /
RewriteRule .* index.html [L]

That redirects all requests to index.html, even requests for images etc.

ayksolutions
12-16-2005, 08:30 AM
Thanks for the post. Could you explain what [L] stands for? I understand that the .* means all the files and rewritebase is used to signify the root directory for that account?

Thanks

maxymizer
12-16-2005, 09:24 AM
[L] is for Last.
[L] is used to stop the next rule from parsing the pattern if previous rule matched it.
You can remove it in this case, since there is only one rule involved, but I use it automatically these days so I accidentaly left it there.. :)

Regarding RewriteBase - a perfect explanation can be found at http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html#RewriteBase

But you got it ok :)

In case you'd like to let images "slip" trough the rewrite process, you could use this:

RewriteRule !\.(gif|GIF|JP?G|jp?g|)$ index.html