1
votes

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?

2

2 Answers

2
votes

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.

1
votes

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.