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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:11:37+00:00 2026-05-13T08:11:37+00:00

I have a subdomain setup as onlinedev.domain.com I need to use htaccess to rewrite

  • 0

I have a subdomain setup as onlinedev.domain.com
I need to use htaccess to rewrite to domain.com/online_content, while still showing onlinedev.domain.com in the address bar (SSL is for onlinedev.domain.com).
this is what I currently have that is very close:

php_flag display_errors off

RewriteEngine On 
RewriteCond %{HTTP_HOST} !^$ 
RewriteCond %{HTTP_HOST} onlinedev\.domain\.com$ [NC] 
RewriteCond %{HTTP_HOST}<->%{REQUEST_URI} ^(www\.)?([^.]+).*<->/([^/]+) [NC] 
RewriteCond %2<->%3 !^(.*)<->\1$ [NC] 
RewriteRule ^(.+) /%2/$1 [L]

This correctly rewrites to domain.com/onlinedev, but if I try to change the RewriteRule to:

RewriteRule ^(.+) /online_content/$1 [L]

I get an error

I understand that there are typically better ways to do this subdomain work, but without getting into server config and DNS details, I need to do it with htaccess.

And yes, I do need to rewrite to a directory that has a different name than the subdomain.

  • 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-13T08:11:38+00:00Added an answer on May 13, 2026 at 8:11 am

    Well, I figured it out.
    The issue was that I was causing an infinite loop.
    Once the rewrite had happened, it was still trying to rewrite to the directory.
    Here is my new htaccess that took care of it:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^$ 
    RewriteCond %{HTTP_HOST} onlinedev\\.domain\\.com$ [NC] 
    RewriteCond %{REQUEST_URI} !^/online_content/
    RewriteRule ^(.+) /online_content/$1 [L]
    

    Notice that I added a check to make sure that the REQUEST_URI is not the name of the directory I am rewriting to.

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

Sidebar

Related Questions

I currently have a subdomain i need to keep in tact: www.sub.domain.com I also
I'm wondering, if I have an .htaccess rewrite setup on a virtual subdomain, ie.
I have a domain foo.com on server bar. I have a subdomain api.foo.com which
Actually I have a domain - domainone.com I have created a subdomain cname of
I have domain site.com and there is subdomain sub.site.com Once you open sub.site.com you
I have this htaccess setup on my clients site, they use godaddy RewriteEngine On
I have this code for managing a subdomain alias: browsing sub.domain.com it shows domain.com/fp/sub.
I have setup a CodeIgniter Application on my server at the following URL: http://subdomain.domainame.com/something1/something2/
Say I have a subdomain xxx.yyy.com running Apache. The files are stored in /home/someone/public_html/xxx
I have the basic code to rewrite a subdomain to another page. But how

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.