Aerodynamika
Aerodynamika

Reputation: 8413

.htaccess redirect from a URL to the site

I want to set up the redirect, which would bring any user from

http://vps.domain.com/~access/ (and subfolders, such as /~access/user etc.)

to

http://www.example.com

What's the Rewrite rule I have to use?

Will that one work?

RewriteCond %{HTTP_HOST} ^vps.domain.com/~access/$
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

Thank you!

Upvotes: 0

Views: 16

Answers (2)

anubhava
anubhava

Reputation: 785316

You can place this rule in ~access/.htaccess:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^vps\.domain\.com$ [NC]
RewriteRule ^ http://www.example.com/ [L,R=301]

Upvotes: 2

bloodyKnuckles
bloodyKnuckles

Reputation: 12089

RewriteCond %{HTTP_HOST} ^vps\.domain\.com [NC]
RewriteCond %{REQUEST_URI} ^/~access/
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

Upvotes: 1

Related Questions