1

I want to change the URL structure of my site, and I need to make some redirects, basically i want:

www.root.com/folder/second_folder/file.php to redirect to folder.root.com/second_folder/file.php

Is there anyway that I could force to redirect the first url, to the subdomain url? I also have some specific root URL's that I want to redirect to specific folders in the subdomain.

I tried various ways and nothing works so far, but only by placing my htaccess file in the root folder. If I place it in my subdomain folder, then it breaks all together.

Thank you.

Alex898
  • 13
  • 2

1 Answers1

0

Place this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?root\.com$
RewriteRule ^([^/]+)/(.+?\.php)$ http://$1.root.com/$2 [L,R=301,NE]
anubhava
  • 761,203
  • 64
  • 569
  • 643