htaccess redirect hide subfolder in url

0 votes

I've looked around and have attempted some rules and conditions that worked; while some did not work or the condition would capture too much causing other domains to also redirect. This works for me:

# Redirect (also catches www.)
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteRule ^(/)?$ subfolder [L]

resulting in if you visit www.domain.com OR domain.com being redirected to domain.com/subfolder Great, but I'dd also like the /subfolder part to be hidden from the url.

How do I achieve this?

Note that I have multiple domains, each should redirect to its own folder. I also want each page to still be visible in its respective folder.

So www.domain.com/abc should redirect to domain.com/subfolder/abc but show domain.com/abc

Jul 10, 2018 in AWS by Hammer
• 360 points
6,248 views

1 answer to this question.

0 votes

I found this after searching,

Try this rule:

# remove www
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [NE,R=301,L]

RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$
RewriteRule !^subfolder/ /subfolder%{REQUEST_URI}  [L]

This can be the way to approach.

answered Aug 10, 2018 by Priyaj
• 58,020 points

Related Questions In AWS

+1 vote
0 answers
0 votes
1 answer

Why my new server shows numbers in the URL address?

It looks like the URLs for your ...READ MORE

answered Feb 17, 2023 in AWS by anonymous
633 views
+3 votes
6 answers

Renaming files in S3

You can either use AWS CLI or ...READ MORE

answered Oct 16, 2018 in AWS by petter dj
31,206 views
+2 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 58,020 points
2,714 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,034 views
0 votes
2 answers

Receiving SMS from users and stores in AWS

As far as I know, receiving international ...READ MORE

answered Aug 21, 2018 in AWS by Priyaj
• 58,020 points
1,625 views
+1 vote
2 answers

How do I get my AWS Glue client in JAVA?

Hey, you've been using a correct code ...READ MORE

answered Apr 17, 2018 in AWS by Cloud gunner
• 4,670 points
4,922 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP