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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:20:25+00:00 2026-06-03T10:20:25+00:00

Background I have a CakePHP application that lives in /m/ . I want to

  • 0

Background

I have a CakePHP application that lives in /m/. I want to write a root-level .htaccess file which will redirect “subdomains” for the site as parameters to actions.

For example: I want to write a rewrite rule which will result in redirects like this –

  • http://mysite.myserver.com → http://myserver.com/m/mysite/
  • http://mysite.myserver.com/home → http://myserver.com/m/mysite/home
  • http://mysite.myserver.com/foo/bar?baz=true → http://myserver.com/m/mysite/foo/bar?baz=true

Ideally, this redirect should be invisible to users (I don’t want to use a 301, because I don’t want to change the URL).

Here’s my current attempt:

<IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine on
  RewriteCond %{HTTP_HOST} ^(.*)\.myserver\.com$ [NC]
  RewriteRule ^(.*)$ http://myserver.com/m/%1/$1 [L]
</IfModule>

As far as I can tell, the main issue is with $_SERVER['REQUEST_URI']:

  • If I browse to http://myserver.com/m/mysite/home directly, $_SERVER['REQUEST_URI'] = /m/mysite/home.
  • If I browse to http://mysite.myserver.com/home using the .htaccess file above, $_SERVER['REQUEST_URI'] = /home.

The Issue

Because of the issues with $_SERVER['REQUEST_URI'], my routes aren’t parsing correctly: it’s trying to take the user to /home rather than /m/mysite/home as desired.

How can I change my rewrite rule to make this work properly? Is there another way to accomplish this?

  • 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-03T10:20:27+00:00Added an answer on June 3, 2026 at 10:20 am

    What you’re asking (change the domain name in URL but don’t let browser see URL change) is not achievable under normal scenario. However to make it possible you have enable mod_proxy in your Apache and restart it. Once that is done use following code in your site root .htaccess:

    RewriteCond %{HTTP_HOST} ^([^.]+)\.myserver\.com$ [NC]
    RewriteRule !^m/ http://myserver.com/m/sites/%1%{REQUEST_URI} [NC,L,P]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background : I have a few different threads which each need to write to
Background I have a ror application which is continuously recording and showing on a
Background: I have a post-build process that copies a file to another location. It
Background: we have an application that generates reports from HTML (that may or may
Background: I have a winform application written in VB.NET that uses a WebService to
Background have a custom UITableCellView in which I'm using a custom UITextField that I've
Background : I have a C# Windows Forms application that contains a Windows service
Background I have an application that is auto-started when a node is started (using
Background I have two lists, the first is items which contains around 250 tuples,
Background I have a function that takes a config object as an argument. Within

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.