-2

The below is original .htaccess, i want to modify it to point to a different folder such as www.yourdomain.com/clients/foldername. How do i do it?

 RewriteEngine On
 RewriteBase /
 RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
 RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

do let me know what i should do that it point to that particular folder. Should i write like this

 RewriteEngine On
 RewriteBase /
 RewriteCond %{HTTP_HOST} ^www\.yourdomain(.*)$ [NC]
 RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

do help me

Joshua Dannemann
  • 2,003
  • 1
  • 14
  • 34
Yusuf
  • 11
  • 2
  • What do you mean point to a different folder. You want all requests to point to /clients/. So you just want to add the clients folder? – Panama Jack Oct 27 '15 at 20:09
  • Possible duplicate of [URL rewriting with PHP](http://stackoverflow.com/questions/16388959/url-rewriting-with-php) – Farkie Oct 27 '15 at 22:22
  • Basically i'm moving a live site to a test environment, so I'm placing this live site in a sub folder under a test environment called www.yourdomain.com/clients/foldername. So how do it rewrite this .htaccess to match it. Please let me know. – Yusuf Oct 28 '15 at 04:00

1 Answers1

0

This should take care of it.

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ your/new/directory/$1 [R=301,L]

This will match all requests. If you only want to redirect certain folders to another you will need to change the RegEx on the RewriteRule.

RewriteRule ^some/path/to/redirect(rest/of/the/uri)$ your/new/directory$1 [R=301,L]

To redirect to a different domain use a RewriteRule like this.

RewriteRule ^(.*)$ http://the.newdomain.tld/your/new/directory/$1 [R=301,L]
Wes Dean
  • 81
  • 6
  • Thanks Wes Dean, but it's giving me 500 Server Error. Basically i'm moving a live site to a test environment, so I'm placing this live site in a sub folder under a test environment called www.yourdomain.com/clients/foldername. So how do it rewrite this .htaccess to match it. Please let me know. – Yusuf Oct 28 '15 at 03:58
  • Is this all under the same domain name and on the same server? Also, is the code capable of being run in a subfolder? Some code uses absolute paths from the document root. Some code modifications may be needed. To test the redirect just put an index.html page in the target folder. This will help you debug the redirect. – Wes Dean Oct 29 '15 at 12:01
  • No it's on different server altogether I placed a test index.html and it showed me test. – Yusuf Oct 29 '15 at 12:51