Mark
Mark

Reputation: 18204

.htaccess how can I virtual redirect m.website.com to website.com/mobile?

I have the following structure:

What I want is that if people would visit http://m.website.com to still see that URL in their browser but it loads the files in the mobile directory. Is that possible?

(Or does anyone have a very good tutorial on .htaccess so I can learn how to do it?)

Upvotes: 1

Views: 470

Answers (1)

Ulrich Palha
Ulrich Palha

Reputation: 9529

try adding the following to your htaccess file in the root directory of what I assume is the m.website.com subdomain.

RewriteEngine on
RewriteBase /

#if they came on mobile domain
RewriteCond %{HTTP_HOST} ^m\.website\.com$ [NC]
#rewrite request to Mobile folder
RewriteRule (.*) mobile/$1 [L]

Upvotes: 2

Related Questions