Question

redirect .. stupid and basic question but I don't know how to fix it

Posted January 9, 2021 168 views
Apache

Hi there
I have my site up and running, domain.com and www.domain.com works fine, the redirect works, but if I create a folder domain.com/folder works, but www.domain.com/folder takes me back to the homepage.
I’ve checked the htaccess and nothing caught my attention there

Any ideas how to fix that?
Sorry for being so basic but all the articles I’ve been reading are mostly chinese for me :(

I have a droplet running Ubuntu 20.04, apache, mysql, php and couple other things in case that helps

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
2 answers

Hello, @puntadigital

Could you please confirm that you would like www.domain.com to redirect to domain.com but also to have www.domain.com/folder without redirecting back to domain.com?

If you want to redirect domain.com/folder/ to www.domain.com/folder/ you can use this .htaccess rule:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{REQUEST_URI} ^/folder/
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

Hope that this helps!
Regards,
Alex

Thank you Alex !
I forgot to mention, looking to simplify the explanation, that “folder” was an example, the folder name is a name the system creates for each registered user, so is dynamic, I have just a few users now, but hope to get more, so I have no idea how to fix that for now and the future.
Trying to get a hold of the person that developed the php script I’m using, maybe he can help.