Jump to content

Routing subdomain to subfolder


lucashermsen

Recommended Posts

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

Link to comment
Share on other sites

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 by requinix
Link to comment
Share on other sites

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 by requinix
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.