Nika Tsogiaidze
Nika Tsogiaidze

Reputation: 1097

Change root path from .htaccess

I would like to change "/" to "/folder".

So when user clicks link with this url "/page.php" I want it to be automatically translated by .htaccess to "/folder/page.php".

How can I achieve this?

Upvotes: 1

Views: 3451

Answers (2)

anubhava
anubhava

Reputation: 784958

This simple rule should work for you in site root .htaccess (parent directory of folder):

RewriteEngine On

RewriteCond %{REQUEST_URI} !^/folder/ [NC]
RewriteRule .* folder/$0 [L]

Upvotes: 2

Vaisakh TechCThree
Vaisakh TechCThree

Reputation: 41

Please use .htaccess file. i think its better for you.

Your Need is:

HTTP://YOUR_DOMAIN.COM/page.php

TO 

HTTP://YOUR_DOMAIN.COM/FOLDER/page.php

Step1:

create an .htaccess file on your Server

Filename: .htaccess

just Copy this part and Change the Values.

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} YOUR_DOMAIN.COM$ [NC]
RewriteCond %{HTTP_HOST} !FOLDER
RewriteRule ^(.*)$ http://YOUR_DOMAIN.COM/FOLDER/$1 [R=301,L]

Reference-1 | Reference-2

Upvotes: 1

Related Questions