Kim Tan
Kim Tan

Reputation: 114

Redirect subfolder to root domain

I want to redirect the subfolder and allcontents to root domain.

For example:

http://www.example.com/ubb/ will redirect to http://www.example.com

I put the .htaccess on ubb folder and the code is:

RewriteEngine On
RewriteRule ^.*$ / [R=302,L]

However when you access http://www.example.com/ubb/threads.php it will redirect to http://www.example.com/threads.php it should be http://www.example.com

Is there any code to try or other possible solution?

Upvotes: 1

Views: 543

Answers (2)

Abhineet Verma
Abhineet Verma

Reputation: 1028

It's achievable using PHP which will be quiet easier I believe.

Create index.php inside ubb folder & add this code to it.

index.php

<?php
header('Location: http://www.example.com/');
?> 

It'll redirect all request coming to www.example.com.

Upvotes: 1

anubhava
anubhava

Reputation: 786091

Place this rule in /ubb/.htaccess:

RewriteEngine On
RewriteBase /ubb/

RewriteRule ^ /? [R=302,L]

Also test it out in a different browser to avoid existing browser caches.

Upvotes: 2

Related Questions