Catfish
Catfish

Reputation: 19314

.htaccess redirect from 1 url (no matter what file/folder) to another url

I have a website http://rochesterwaterskishow.com which they've recently changed their name so they want to update their url to http://skidox.com. I'm trying to redirect any page from rochesterwaterskishow.com to skidox.com/site/index.

I have this line of code which redirects http://rochesterwaterskishow.com to http://skidox.com, but if I go to something like http://rochesterwaterskishow.com/test, it doesn't redirect to http://skidox.com.

RewriteRule ^$ http://skidox.com/site/index [R=301,L]

How can I make it a catch all so anything rochesterwaterskishow.com/* gets redirected to skidox.com/site/index?

UPDATE: Full .htaccess file

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

RewriteRule ^$ http://skidox.com/site/index [R=301,L]

Upvotes: 0

Views: 830

Answers (2)

ionFish
ionFish

Reputation: 1024

RewriteRule ^$ http://skidox.com/site/index/$1 [R=301,L]

Upvotes: 0

TerryE
TerryE

Reputation: 10898

That's because the search pattern ^$ will only match a URI path of "/". You need to pick up the request in a match variable, for example:

RewriteCond %{HTTP_HOST} rochesterwaterskishow
RewriteRule ^.*          http://skidox.com/site/index/$0     [R=301,L]

I am assuming that you are using SEO optimised-style URIs for the new site. If you want to simply redirect everything to the index page without any context, then you still need a pattern that matches:

RewriteCond %{HTTP_HOST} rochesterwaterskishow
RewriteRule ^            http://skidox.com/site/index        [R=301,L]

Update following post of full htaccess

RewriteEngine on
RewriteBase   /

RewriteCond %{HTTP_HOST}        rochesterwaterskishow
RewriteRule ^.*                 http://skidox.com/$0  [R=301,L]

RewriteCond $0                  ^(index\.php$|robots\.txt$|resources)
RewriteRule ^.*                 -                     [S=1]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$              index.php/$1          [L,QSA]

Upvotes: 1

Related Questions