0

I read another post on SO but it didn't work for me... I would like to access from https://VALUE.example.com - what is currently available at https://example.com/folder/VALUE/

I tried:

RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.example\.com$ [OR] RewriteCond %{HTTP_HOST} ^.example\.com$ RewriteRule ^folder/([^/]+)/?$ https://$1.example.com/ [NC,R=301,L] 

but it didn't work... any idea?

I took this as reference: Rewrite folder to subdomain

1 Answer 1

1

I have redefined your code a little bit:

RewriteEngine On RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC] RewriteRule ^/?folder/([^/]+)(/.*)?$ https://$1.example.com/ [R=301,NC,L] 

In your second line there wad on . to much, so example.com (without the www.) could not work. Than you can combine both RewriteCond lines in one. Last but not least, if the original URL have something additional e.g. https://example.com/folder/VALUE/something-here than it could also not work.

One additional remark: The whole thing would only work if on your server mod_rewrite is enabled and you are allowed to use htaccess files (with mod_rewrite), this is not always the case.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.