Apache .htaccess subdomains ?

Posted on 2006-05-02
Last Modified: 2012-06-27
I need .htaccess file that would allow me to access my site with any subdomain. For example if i type or that show me file sub1.txt or sub2.txt.. but i i want that subdomain stays the same.

example: to show sub1.txt without redirection to sub1.txt, so must stay in link bar.

Thank you !
Question by:65zgtre45rr
    LVL 10

    Expert Comment


    DirectoryIndex sub1.txt
    LVL 27

    Accepted Solution

    > if i type or that show me file sub1.txt or sub2.txt.

    You'll need mod_rewrite for that

    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteCond %{HTTP_HOST} ^([^.]+)\.site\.com
    RewriteRule ^$ /%1.txt [L]

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
    If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now