Reputation: 111
I didn't know where to ask this as I'm new to htaccess stuff. I created a .htaccess file in the root of my web site. In the public_html folder.
When i type in the site, this is what it gives me.
www.example.com/coming-soon/coming-soon/coming-soon/coming-soon/coming-soon/coming-soon/coming-soon/coming-soon/coming-soon/coming-soon/coming-soon/coming-soon/coming-soon/coming-soon/coming-soon/coming-soon/coming-soon/coming-soon/coming-soon/coming-soon/coming-soon/
Im trying to redirect site.com to site.com/coming-soon.
I only have one .htaccess file and it reads.
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
<IfModule mod_setenvif.c>
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
</IfModule>
<IfModule mod_headers.c>
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>
</IfModule>
Redirect 302 / http://www.example.com/coming-soon/
I can't seem to figure out why its pointing to multiple sub folders like that.
Upvotes: 2
Views: 64
Reputation: 111
Starkeens answer worked perfectly using the RedirectMatch method. I did find why my version of redirect wasn't working properly.
Redirect 302 / http://www.example.com/coming-soon/
By using only a slash, it was trying to find every instance of a folder and file and redirect that folder/file to the coming soon page.
By using explicitly >
Redirect 302 /index.html http://www.example.com/coming-soon/
It tells the server to explicitly look for the index file, which is the file it uses when you type it website.com, and then transfers the person the where ever you choose. Hope this helps someone.
Upvotes: 0
Reputation: 41229
This is because of the greedy behaviour of Redirect directive. it tries to match all Incoming uris including /coming-soon.
You can use RedirectMatch with regex pattern to redirect just the homepage .
RedirectMatch 302 ^/$ /coming-soon
Upvotes: 1