Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7589143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:05:26+00:00 2026-05-30T20:05:26+00:00

I need to use a subdomain as a class. ie, instead of: www.example.com/class/function/ID eg

  • 0

I need to use a subdomain as a class. ie, instead of:

http://www.example.com/class/function/ID eg http://www.example.com/town-name/history/1

I need

class.example.com/function/ID eg town-name.example.com/history/1

I’ve wildcarded the subdomain in nginx, now I’ve googled and read

http://codeigniter.com/user_guide/libraries/uri.html

http://codeigniter.com/user_guide/general/urls.html

http://codeigniter.com/user_guide/helpers/url_helper.html

but nothing relevant. I need it to be so that if another town is added to the db, it’ll resolve that new town and its details.

I see many discussions about rewrites, redirects etc, but I specifically need to use the subdomain town name as the class variable. If possible, in an idea world, I could use both together, but I doubt that’s possible?

I’ve had it going fine in plain old php for a couple of years now; now I want to upgrade to codeigniter without ruining my old structure if possible (plus there’s a good reason for it).

Thanks you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:05:27+00:00Added an answer on May 30, 2026 at 8:05 pm

    You can do it. I’m doing it for one of my projects.

    In the constructor of your controller, just explode the current url and get the subdomain and pass it in your method as a variable

    public class Controller extends CI_Controller {
    
        $subdomain = null;
    
        public __construct() 
        {
            // explode url here and set $this->subdomain = the actual subdomain
        }
    
        public function index() 
        {
            if($this->subdomain == null) {
                show_404();
            } else {
                // do what you wish
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a subdomain setup as onlinedev.domain.com I need to use htaccess to rewrite
Need to use own imaged markers instead built-in pins. I have several questions. 1.
I need to run my development through nginx due to some complicated subdomain routing
I have a main website running on AppEngine. It's on a subdomain like main.example.com
I changed all my static content references to use the static. subdomain instead of
I need to check my subdomain name (or if theres no subdomain) in asp.net.
Need to have example.com/directory-1 and example.com/directory-2 run different versions of PHP. Both versions are
I need to use sed to convert all occurences of ##XXX## to ${XXX} .
I need to use an alias in the WHERE clause, but It keeps telling
I need to use NSImage which appears need to be imported from <AppKit/AppKit.h> .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.