0

Trying to get

www.example.com

to go directly to

www.example.com/forum

How can I do this with this configuration? Thanks in advance.

Edit: Right now I have added below content in .htaccess

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

I want result like

https://www.example.com/topic/topic-url/

to

https://www.example.com/forum/topic/topic-url/
RavinderSingh13
  • 130,504
  • 14
  • 57
  • 93
  • 2
    Welcome to SO, please share your tried .htaccess rules file in your question, showing efforts by Original poster of question is highly encouraged on SO. – RavinderSingh13 Dec 28 '20 at 06:14
  • Does this answer your question? [.htaccess rewrite to redirect root URL to subdirectory](https://stackoverflow.com/questions/990392/htaccess-rewrite-to-redirect-root-url-to-subdirectory) – Joe Dec 28 '20 at 06:15
  • "...with this configuration?" - With _what_ configuration? You've not said anything about your configuration. – MrWhite Dec 29 '20 at 17:02

1 Answers1

1

With your shown samples, could you please try following. Please clear your browser cache before testing your URLs. Your tried rules will be creating an infinite loop hence it may not be working, I have added a condition if uri doesn't start from forum then only proceed with redirection.

RewriteEngine ON
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [NE,R=301,L]

RewriteCond %{REQUEST_URI} !^/forum [NC]
RewriteRule ^(.*)$ /forum/$1 [L,R=301]
RavinderSingh13
  • 130,504
  • 14
  • 57
  • 93