: "example.com" forwards to "www.example.com", but "example.com/file.pdf" just forwards to "www.example.com". How to fix? I don't know much anything about how hosting works, so if there's any additional
I don't know much anything about how hosting works, so if there's any additional info I should provide, please let me know.
The URL example.com correctly forwards to example.com. But example.com/file.pdf and example.com/some-blog-post also forwards to example.com rather than example.com/file.pdf and example.com/some-blog-post as I'd like them to.
How can I set this up properly?
I'm hosting my personal website on GitHub pages, with a custom domain name through Namecheap. My current set up is the following:
Host Name IP Address / URL Record Type @ www.example.com URL Redirect
www example.github.io CNAME (Alias)
And the GitHub repository "example.github.io" contains a CNAME file at the top level that just contains the text
example.com
More posts by @Caterina187
3 Comments
Sorted by latest first Latest Oldest Best
First of all,you need to know type of content. redirection is perfect.
If you are redirecting based on server config(Apache), it is perfect.
example.com/file.pdf deposit as file and its source is example.com
so example.com redirect to example.com as deposit content as pdf
Upto this level,it is working fine.
You have implemented this redirect with Namecheap. Their help document explains how to set up the redirects either way:
www1 destination.com Permanent (301)
www2 destination.com/ Permanent (301)
In the above case, www1.yourdomain.com will not pass values to the destination URL so, www1.yourdomain.com/xyz.html will redirect users to destination.com only.
On the otherhand, www2.yourdomain.com/xyz.html will redirect users to destination.com/xyz.html (pay attention to the / in the configuration).
So in Namecheap's interface, you need to ensure that your redirect rules have a trailing slash on the destination.
What you could do is make example.com and example.com as separate URLs pointing to two different folders on the server, but make example.com point to the folder with the website contents.
Then these lines can be added to apache's main configuration file (httpd.conf) if you have mod_rewrite installed.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule ^(.*)$ www.example.com/ [R=301,L]
Just make sure they are added before custom RewriteRule lines are processed for the example.com website if any.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2025 All Rights reserved.