lucashermsen Posted January 6, 2013 Share Posted January 6, 2013 Dear forum members, My hoster redirects all traffic to subdomain.domain.com to domain.com/subdomain. Since I work with CodeIgniter, I would like it to route it to domain.com/applications/subdomain. Therefore, I have written an htaccess in the root folder: RewriteEngine on RewriteRule ^subdomain(.*)$ /applications/subdomain.php/$1 [L] However, this gives an internal server error (500). Does anybody have a clue how I can best do this? Best regards Lucas Quote Link to comment https://forums.phpfreaks.com/topic/272756-routing-subdomain-to-subfolder/ Share on other sites More sharing options...
requinix Posted January 6, 2013 Share Posted January 6, 2013 (edited) 1. Are you sure they're actually redirecting traffic to that location and not, say, setting the document root of the subdomain to be a subfolder under wherever the domain.com files are kept? (eg, /home/lucashermsen/domain.com/subdomain) 2. Do you have mod_rewrite installed? Just checking. 3. What does Apache's error log say about the 500 error? Edited January 6, 2013 by requinix Quote Link to comment https://forums.phpfreaks.com/topic/272756-routing-subdomain-to-subfolder/#findComment-1403588 Share on other sites More sharing options...
lucashermsen Posted January 6, 2013 Author Share Posted January 6, 2013 I think they are indeed doing this: "setting the document root of the subdomain to be a subfolder under wherever the domain.com files are kept? (eg, /home/lucashermsen/domain.com/subdomain)" What can I do to have subdomains use the /application/subdomain/ folder? Quote Link to comment https://forums.phpfreaks.com/topic/272756-routing-subdomain-to-subfolder/#findComment-1403590 Share on other sites More sharing options...
requinix Posted January 6, 2013 Share Posted January 6, 2013 I'm not that familiar with CI: is application/ an actual directory or just a part of the URL? Quote Link to comment https://forums.phpfreaks.com/topic/272756-routing-subdomain-to-subfolder/#findComment-1403595 Share on other sites More sharing options...
lucashermsen Posted January 6, 2013 Author Share Posted January 6, 2013 It's an actual directory and the contents are loaded by /application/subdomain.php. So with RewriteRule ^subdomain(.*)$ /applications/subdomain.php/$1 [L] I actually wanted to load the subdomain.php file in /applications/ Quote Link to comment https://forums.phpfreaks.com/topic/272756-routing-subdomain-to-subfolder/#findComment-1403598 Share on other sites More sharing options...
requinix Posted January 6, 2013 Share Posted January 6, 2013 (edited) If you don't mind people actually being redirected to domain.com/application/subdomain.php then you can do that: create a .htaccess in the domain.com/subdomain folder with Redirect permanent / http://www.domain.com/application/subdomain.php Otherwise if the URL has to still show the subdomain then in that same .htaccess try RewriteEngine on RewriteRule ^ /full/path/to/domain.com/application/subdomain.php%{REQUEST_URI} [L] # if that doesn't work then try without the ${REQUEST_URI} ...and if that doesn't work either then I'm not sure. I don't think [PT] will help because the target isn't a URL, can't use Alias in a .htaccess... Might have to find some way to force the PATH_INFO variable. [edit] All this assumes that CI won't muck around with the URL, like change the hostname or automatically include "/application/subdomain.php" or something equally fatal. Edited January 6, 2013 by requinix Quote Link to comment https://forums.phpfreaks.com/topic/272756-routing-subdomain-to-subfolder/#findComment-1403605 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.