FirefoxRocks 0 Report post Posted March 13, 2009 (edited) I would like to know if pages can redirect to the subdomain URL instead of the folder in public_html.For example:http://forums.xisto.com/no_longer_exists/ goes to http://forums.xisto.com/no_longer_exists/ where I have a folder called feral in my public_html folder.I want http://forums.xisto.com/no_longer_exists/ to go to http://forums.xisto.com/no_longer_exists/ and the pages within the feral directory to do that too. (e.g. http://forums.xisto.com/no_longer_exists/armyCalc.php to http://forums.xisto.com/no_longer_exists/armyCalc.php).How do I do this within cPanel? Edited November 29, 2009 by FirefoxRocks (see edit history) Share this post Link to post Share on other sites
Nabb 0 Report post Posted March 15, 2009 You could try hacking something up using mod_rewrite. For example, you could rewrite http://forums.xisto.com/no_longer_exists/ to http://forums.xisto.com/no_longer_exists/=, which would redirect them based on the value in q. Hopefully this doesn't cause an infinite redirection loop.. Share this post Link to post Share on other sites
tansqrx 0 Report post Posted March 16, 2009 Create a subdomain under your Cpanel1. Log into your Cpanel.2. Click Subdomains under the Domains group.3. Enter âferalâ in the Subdomain field4. Enter âferal/â in the Document Root field.5. Click Create.If all goes well and I understand what you want then this should be your solution. http://forums.xisto.com/no_longer_exists/ should redirect to your /feral/ directory. Share this post Link to post Share on other sites
FirefoxRocks 0 Report post Posted March 20, 2009 Create a subdomain under your Cpanel1. Log into your Cpanel.2. Click Subdomains under the Domains group.3. Enter "feral" in the Subdomain field4. Enter "feral/" in the Document Root field.5. Click Create.If all goes well and I understand what you want then this should be your solution. http://forums.xisto.com/no_longer_exists/ should redirect to your /feral/ directory. Other way around, I want the /feral directory to redirect to the subdomain. Share this post Link to post Share on other sites
Quatrux 4 Report post Posted March 21, 2009 You need to use htaccess files in order to do this, one way is to use mod_rewrite, here is the code: Options -Indexes +FollowSymLinksRewriteEngine OnRewriteBase /RewriteCond %{HTTP_HOST} ^example.com [NC]RewriteRule ^(.*)$ http://example.com [L,R=301]RedirectMatch 301 ^/blog/(.*)$ http://blog.example.com/$1 So whenever someone will go to example.com/blog/ it will redirect him/it to your subdomain blog.example.com with a permanent redirect code 301, which is good for lets say spiders and other web robots.More about it on this blog entry I found through google: http://terriswallow.com/2008/03/11/htacce-and-force-www/Another way would be doing the same thing with PHP, if you're using index.php you just need to check $_SERVER superglobal HTTP_HOST as I remember if it's not blog.example.com but only example.com also redirect with a 301 code using header() + Location, it will do the same, but I believe using htaccess method is much better, as I think it will also redirect example.com/blog/images/Logo.jpg to blog.example.com/images/Logo.jpg where using PHP would only redirect dynamic pages. Share this post Link to post Share on other sites
TavoxPeru 0 Report post Posted April 1, 2009 Excelent information Quatrux, some time ago i had try to do something similar with bad results, i never can made it to work. When i have some spare time i will try again, i hope now it works. Best regards, Share this post Link to post Share on other sites
FirefoxRocks 0 Report post Posted April 6, 2009 Do I put this htaccess file within the /feral/ directory or the / root directory? And I would prefer to redirect all resources, not just the PHP pages. Share this post Link to post Share on other sites
Quatrux 4 Report post Posted April 6, 2009 I guess it's enough to put the .htaccess file in you root directory of subdomain.example.com so whenever someone goes to any resource in example.com/subdomain/ he will get redirected to the same resource through the subdomain.example.com Share this post Link to post Share on other sites
iGuest 3 Report post Posted November 8, 2009 ThanksSubdomain RedirectionQuatrux, thank you so much for posting this. Exactly what I was looking for and I searched everywhere for this.. -reply by Deran Share this post Link to post Share on other sites
Xamire 0 Report post Posted May 29, 2011 (edited) You can either use cpanel to forward them, or do what I do, and use a simple .htaccess file Make a text file, name it htaccess - add this info: Redirect 301 / http://forums.xisto.com/no_longer_exists/ Then you simply upload via ftp, and use it in whatever directory you need it in. (main file if using Xisto to the site above), and then rename it with a period in front of the htaccess (.htaccess). Very easy to do, and works well. Edited May 29, 2011 by xamire (see edit history) Share this post Link to post Share on other sites