0
votes

I have a client site who's business is closing. They want to keep their site up for now, but what they also want is that going to any previous URL, automatically redirects people to the homepage.

I've tried a number of ways to do it in .htaccess like the following:

RedirectMatch permanent .* http://www.hotskitchen.com

But nothing has worked. The only thing that happens is that the stylesheet goes away. What can I do to make this redirect work beyond writing lots of 301 redirects from individual pages?

Here's the complete .htaccess

# BEGIN W3TC Page Cache core
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP:Accept-Encoding} gzip
    RewriteRule .* - [E=W3TC_ENC:_gzip]
    RewriteCond %{HTTP_COOKIE} w3tc_preview [NC]
    RewriteRule .* - [E=W3TC_PREVIEW:_preview]
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} =""
    RewriteCond %{REQUEST_URI} \/$
    RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]
    RewriteCond "%{DOCUMENT_ROOT}/wordpress/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" -f
    RewriteRule .* "/wordpress/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" [L]
</IfModule>
# END W3TC Page Cache core
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>

# END WordPress

Redirect 301 /about http://www.hotskitchen.com/about-hots-kitchen/
Redirect 301 /about/our-concept http://www.hotskitchen.com/about-hots-kitchen/our-concept/
Redirect 301 /about/the-people http://www.hotskitchen.com/about-hots-kitchen/the-people/
1
Redirect 301 / http://www.hotskitchen.com/ should work. If it is not working then probably your .htaccess isn't enabled.anubhava
Nope. That didn't work either. And .htaccess is enabled. I know that because I had previous redirects set up there for three pages I was redirecting.Adam Bell
ok, can you show your full .htaccess in questionanubhava
I have to place it in the main post. Won't let me do it here due to length.Adam Bell
Nope. Didn't work. All I get is the same webpage with the CSS stripped out. The second method redirected to hotskitchen.com/wordpress/wp-content/cache/page_enhanced/…Adam Bell

1 Answers

0
votes

Should do the trick for .htaccess:

RedirectMatch 301 ^/ http://www.hotskitchen.com/

Personally, I prefer mod_rewrite to achieve this when using Apache:

RewriteEngine On
Redirect 301 / http://www.hotskitchen.com/

Even better, a server listener in nginx for that specific domain name, which will work for any path:

server {
    listen 80;

    server_name www.oldwebsite.com;

    return 301 http://www.hotskitchen.com/;
}