Welcome Guest, Not a member yet? Register   Sign In
contextually use another domain for a controller
#1

[eluser]Unknown[/eluser]
I have a site that uses a CMS I made with CodeIgniter. It's a creative studio site and as such it's broken up into categories and pieces of content (the latter being something like a video or a blog post or a piece of art, etc).

What I want to do is, purely contextually, get one category, and its subcontent, transferred to a dedicated domain (while leaving everything else on the site).

EXAMPLE:

http://www.studio.com/content/foo/ (category "foo")
http://www.studio.com/content/foo/bar/ (content "bar" in category "foo")
http://www.studio.com/content/abc/ (category "abc")
http://www.studio.com/content/abc/def/ (content "def in category "abc")

be able to change that to:

http://www.thisisadomainname.com/ (category "foo")
http://www.thisisadomainname.com/bar/ (content "bar" in category "foo")
http://www.studio.com/content/abc/ (category "abc")
http://www.studio.com/content/abc/def/ (content "def in category "abc")

http://www.studio.com/content/foo/ would most likely still be linked to but just redirect to http://www.thisisadomainname.com/. This'd be purely a URL change -- the site is still studio.com's website, it's just that that one category has a dedicated domain.

I know there's probably some way involving routes and a little bit of htaccess magic but I'm a bit lost. Help would be very appreciated.
#2

[eluser]dudeami0[/eluser]
Well with my host (dreamhost), I usually just direct both domains to the same directory with my codeigniter application. Then in the htaccess, I add something along the lines of:

Code:
#Redirects alt domain to correct controller
RewriteCond %{HTTP_HOST} ^(www\.)?thisisadomainname\.com [NC]
RewriteCond %{REQUEST_URI} !^/?index\.php.* [NC]
RewriteRule ^(.*)?$ /index.php?/foo/$1 [L]

Then all the other info for the main domain below it. An example of this is on my image hosting site in the link below. The i.gfxtub.com is in the same directory as gfxtub.com, just redirects the request to a certain controller and method for the images.

Edit: Also, your urls would have to check which domain is being used, then write the correct url for each one. This step I don't have an answer for but would be happy to help come up with one Smile




Theme © iAndrew 2016 - Forum software by © MyBB