Issue
I have a website that looks like this (the Ferrari is not a physical folder is an alias virtual):
www.example.com/en/ferrari
and I would like to convert this site into a sub-domain, like so:
ferrari.example.com
or something like:
ferrari.example.com/en/
The idea is to have all sub-pages from the Ferrari section working inside the sub-domain.
I don't know if this is even possible, all my .htaccess test didn't worked out. I am searching for a re-write rule but I don't seem to find it.
EDIT:
Let me rephrase the question, I don't want to REDIRECT from example.com/ferrari to ferrari.example.com
What I want is to show the example.com/ferrari site when someone opens ferrari.example.com. That is the difficult part. If someone opens ford.example.com, I want to show all the pages that are inside example.com/ford.
Solution
You can use that in your root .htaccess
:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^ferrari\.example\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/en/ferraricars [NC]
RewriteRule ^(?:en/)?(.*) en/ferraricars/$1 [NC,L]
Work with ferrari.example.com/en/other
and ferrari.example.com/other
-> example.com/en/ferraricars/other
Answered By - Croises Answer Checked By - Terry (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.