I have a site that is no longer needed live and has a holding page setup to state that it's no longer available. All requests to pages on the site (bookmarked or otherwise) need to be sent to this page which is the root index.php page, so I'm using some htaccess to redirect it accordingly.
I'm currently using this:
RewriteCond %{REQUEST_URI} !^/index.php$
RewriteRule ^(.*)$ /index.php [R=302,NC,L]
which does the job, but adds index.php to the url - ie. www.domain.com goes to www.domain.com/index.php
It'd be much nicer to have just www.domain.com, but apparently I can't do that using:
RewriteCond %{REQUEST_URI} !^/$
RewriteRule ^(.*)$ / [R=302,NC,L]
It gives a page not redirecting properly error in firefox.
I'd have expected the above to check to see if the REQUEST_URL isn't / - ie. www.domain.com and then redirect it to / eg. www.domain.com/dave.php -> www.domain.com - thus www.domain.com passes, but everything else is redirected... what's it actually doing and how to I get it to do what I want it to?
Just use it like this :
RewriteRule ^.+$ / [R=302,NC,L]
It will redirect all that don't match /
only to /
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With