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 8617503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:52:31+00:00 2026-06-12T05:52:31+00:00

Sorry if the title is confusing. I have set up a virtual host on

  • 0

Sorry if the title is confusing.

I have set up a virtual host on my local machine. I’ve set http://dev to map to my /htdocs/dev folder. With some help from dnsmasq and .htaccess, I’ve set it up so that it maps subdomains of .dev to folders inside /htdocs/dev. And it all works perfect when I try to access, for example, http://dev/file1.html or http://folder.dev/file2.html. The problem occurs with accessing subfolders. I get a 404 Object not found if I try to access http://folder.dev/subfolder/ or http://folder.dev/subfolder/file3.html.

I guess it can be solved with .htaccess, but I failed to do it although I tried. Here’s how my /htdocs/dev/.htaccess looks like:

# Default index file
  DirectoryIndex index.php

# Interpret .html files as .php scripts
  AddHandler php5-script .php .html

# Redirect subdomains to their respective folders
  RewriteEngine on
  RewriteBase /

  RewriteCond %{HTTP_HOST} !^www\.dev$ [NC]
  RewriteCond %{HTTP_HOST} ^(www\.)?([a-z0-9-]+)\.dev$ [NC]
    RewriteRule !^([a-z0-9-]+)($|/) /%2%{REQUEST_URI} [PT,L]

I should mention that, if I try to access http://dev/folder/subfolder/file3.html, there are no problems.

How can I set addresses such as http://folder.dev/subfolder/ point to /htdocs/dev/folder/subfolder?

  • 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-06-12T05:52:33+00:00Added an answer on June 12, 2026 at 5:52 am

    First, thanks goes to @JonLin for giving me a hint about this.

    I’ve managed to solve this with this .htaccess file:

    # Ordered list of index files, if none exist, show directory listing
      DirectoryIndex index.php index.html
    
    # Interpret .html files as .php scripts
      AddHandler php5-script .php .html
    
    # Redirect subdirectories to their respective folders
      RewriteEngine on
      Options +FollowSymlinks
      RewriteBase /
    
      RewriteCond %{HTTP_HOST} !^www\.dev$ [NC]
      RewriteCond %{HTTP_HOST} ^(www\.)?(.*)\.dev(.*)?$ [NC]
      RewriteRule !^%2\.dev%3?/$ http://dev/%2%{REQUEST_URI}/ [P]
    

    What Rewrite part of this does is it takes a URL in form of http://folder.dev/subfolder and points it to /dev/folder/subfolder while preserving the URL. It works with or without www.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry if the title is confusing. I have several string expressions in an array
Sorry for the title may seem confusing. i have 2 element. with no relation
Hello everybody and sorry for the rather confusing question-title. I have a Hibernate Class
sorry, I realize my title is confusing. Please let me explain. I have a
Sorry if the title seems confusing, but some examples are in order. Let's say
Sorry if the title is confusing. Here is the query I have Select MONTH(DATE(TIMESTAMP)),
Sorry the title isn't more specific. I have some minor problems with a jquery
I'm sorry for the little confusing title but say I have a class with
Sorry about that confusing title :) I have a resource, ComatosePage (used in the
sorry for the confusing title. I have two tables, individu and orgcont . individu

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.