Redirecting to a subdirectory from root

I am new here on InfinityFree and trying to set up my site
To start with I have loaded up the old website in a directory …/ Later I plan to move over the new wordpress site I have developed. I don’t want to fill up the root directory - that being the reason for moving everything to the subdirectory VDP-Old.

My problem is getting traffic directed there. When someone writes I want the redirected to
WHere I had things hosted previously I would set up a redirect to I tried doing this on cpanel by using the redirects: Add/Remove Redirects I changed the to and clicked the button “alter redirects”. On the next page I filled in and clicked the butoon “Redirect itl”. The result was an error message (403) Forbidden You don’t have permission to access /panel/indexpl.php on this server.

What am I doing wrong ?

Anyway I thought I could do it a different way and copied a htaccess file I had from before and placed it in / The file looks like this:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?$
RewriteCond %{REQUEST_URI} !^/VDP-Old/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /VDP-Old/$1
RewriteCond %{HTTP_HOST} ^(www.)?$
RewriteRule ^(/)?$ VDP-Old/index.html [L]

But that didn’t help either. I just get rerouted to the error page:

ANy suggestions for reouting traffic to to ?

Thanks in advance

First setup an custom erorr 404 page. just paste this line below into your .htaccess file

ErrorDocument 400 /400-page.html

And then save your file and revisit your website now you get info about from where you’re redirected to.


Using .htaccess

Place this code into your .htaccess file

DirectoryIndex VDP-Old.html VDP-Old.php VDP-Old.htm

Using PHP
Place this code in the top of your index.html file

header("Location: /VDP-Old");
1 Like

First of all, never use the Redirects tool to redirect back to the same domain or a domain in the same folder. I’m not sure why the tool lets you do this in the first place, because it will always lead to a redirect loop.

Do I understand correctly you ONLY want to redirect and to ? You don’t want to redirect things like to ?

Because if so, I would personally skip the .htaccess route entirely and just create a file with the name index.php and contents like this:

echo "Redirecting...";

If you also want to capture subdomains, that can be done with .htaccess rules, but it’s a bit more involved.


Thanks for trying to help me.

  1. I made an error page and put it in the folder, and modified my htaccess file in the same folder - but it still comes up with the standard infinity error page

  2. I modified the htaccess file in folder according to your suggestions - but no help

  3. I tried adding the PHP code to the top of my index.htm file so the first 3 lines are:
    header(“Location: /VDP-Old”);

but that did not help.

So to iterate:

  1. I have entered an addon address via cpanel - which created a directory and under that a directory called htdocs.
  2. I have manually moved the old site in to a directory
  3. Everything works fine in the root directory (ie
  4. Everything works fine if I type
  5. I am trying to get any user entering or to go one folder down to

I am just having a really hard time getting my head around this

Thanks for the help. To answer your questions - in the folder there was nothing. Everything was in . By everything I mean htm files and image folder with image files. I do not have subdomains.

I wrote an index.php file where I copied the text you specified and placed it in the folder

I wrote an index.php file and copied the text you specified and placed it in the folder - but users still do not get rerouted to the subfolder. However I did discover that if I entered in the browser then things seem to work.

So maybe I am a little closer - but still not there yet.

OK, after a lot of trial and error and googling - this seems to work:

  1. a 404-page.htm for errors in folder
  2. a htaccess file with the content below in the same folder as the error page
# redirect from root to subdirectory
RedirectMatch ^/$ /VDP-Old/

# redirect on 404 to subdirectory
ErrorDocument 404 /404-Page.htm

This is where I found the solution:

Also do note, that the /htdocs folder is not visible in the URL, so


Is not the correct format, htdocs is not included in the url


Thanks - yes I know - I was referring to the location via ftp. But good information for anyone else reading this.

Oh sorry :joy:

in index.php put this

<?php header("Location: example.php"); ?>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.