Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

htaccess redirection

Tags:

php

.htaccess

I have a domain test.com

Now i have the latest files in test.com/backup/

Now , what i need is, when i type test.com in browser it should go to test.com/backup/

How can i write code for that in htaccess file

like image 725
Linto P D Avatar asked Dec 17 '10 22:12

Linto P D


People also ask

What is htaccess redirect?

Using Redirect in an .htaccess file enables you to redirect users from an old page to a new page without having to keep the old page. For example, if you use index.html as your index file and then later rename index.html to home.html, you could set up a redirect to send users from index.html to home.html.

Should I enable 301 .htaccess redirect?

The . Because the WordPress 301 redirect is not always reliable, we recommend issuing the 301 redirect via your . htaccess file. Another benefit is that the . htaccess redirect is slightly faster than redirecting via PHP, because it is loaded even before the rest of the page.


2 Answers

If you want it to be silent:

RewriteEngine on
RewriteRule ^(.*)$ /backup/$1 [L,NC]

This will make http://test.com/ appear to contain the files inside /backup/ without having backup in the url

like image 96
Stephen Avatar answered Oct 23 '22 21:10

Stephen


in your .htaccess file:

Redirect 301 / /backup

like image 21
wajiw Avatar answered Oct 23 '22 22:10

wajiw