Htaccess redirect to another folder on the same domain

I have a website abc.com, I have saved all my files and folders. Now I created a folder called "newsite" and moved all the files there. Now I want my custom type abc.com in the browser to automatically redirect them to abc.com/newsite

I am using a linux server with godaddy hosting. I know it can be done via htaccess file. Can anyone help me with this?

I am using this in my htaccess file but it doesn't work

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.abc.com$
RewriteRule (.*)$ /newsite$1 [R,L]
</IfModule>

      

Thank you so much in advance

+2


source to share


3 answers


This should do it:

Options +FollowSymLinks -MultiViews

RewriteEngine On
RewriteBase /

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

      



RewriteCond

checks if the url starts with /newsite

, if it doesn't redirect the user to it.

+7


source


Try this solution:

RewriteRule ^xxx/?([^/].*)?$ old/xxx/$1 [L]

      



or

 RewriteRule ^(.*)directory(.*)$ $1otherdir$2 [QSA,L,R=301,NC]

      

0


source


Hello friend, that's right:

RewriteEngine On RewriteBase /

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

Only this in your .htacces which are in your public_html folder (site root)

New folder is the folder containing your site files. If you are using Wordpress, use Softaculous to clone all of your website content into a new folder.

Remember that you will need to change the information for your database. ... Log in to your phpMyAdmin account, export your database to a location on your computer (use the Custom option - display all possible options to export and save a backup of the exported database - if you miss anything, you will have this insurance file to import it again).

Then open yourdatabasename.sql file in your php editor, use the replace option and make the following changes:

EX: yoursite.com
(Change option to) yoursite.com/yournewfolder

save the edited file. Now go back to your phpMyAdmin account and delete your old database (by selecting all tables and using the delete option), after deleting go to the Import option and import the new modified database.

Have a great day.

0


source







All Articles