Redirect to another folder with htaccess and hide folder name

I had a paid domain, I put a folder with the domain name (mysite.net) on the server

I don't want to pay for the domain anymore, so I want to use the default subdomain provided by my hosting service (mysitenet.ipage.com), but the problem is what I said above, there is a folder with my paid domain name, for example:

/
  /mysite.net
  /cgi.bin

      

I read this redirect solution:

Options +FollowSymLinks -MultiViews

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} !^/mysite.net[NC]
RewriteRule ^ /mysite.net%{REQUEST_URI} [R=301,L]

      

with these rules i go to mysitenet.ipage.com and redirects me to mysitenet.ipage.com/mysite.net as i want, but is there a way to hide the mysite.net part?

+3


source to share


1 answer


You can put this code in your htaccess (which should be in the folder root

)

Options +FollowSymLinks -MultiViews

RewriteEngine On
RewriteBase /

RewriteRule ^(?!mysite\.net/)(.*)$ mysite.net/$1 [L,QSA]

      




EDIT: if you want to avoid duplicate content and also redirect /mysite.net/something

to/something

Options +FollowSymLinks -MultiViews

RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} \s/mysite\.net/([^\?\s]+) [NC]
RewriteRule ^ %1 [R=301,L]

RewriteRule ^(.*)$ mysite.net/$1 [L,QSA]

      

+1


source







All Articles