"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 info I should provide, please let me know.
The URL example.com correctly forwards to www.example.com. But example.com/file.pdf and example.com/some-blog-post also forwards to www.example.com rather than www.example.com/file.pdf and www.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
@ http://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
www.example.com
You have implemented this redirect with Namecheap. Their help document explains how to set up the redirects either way:
www1 http://destination.com Permanent (301)
www2 http://destination.com/ Permanent (301)
In the above case,
www1.yourdomain.comwill not pass values to the destination URL so,www1.yourdomain.com/xyz.htmlwill redirect users tohttp://destination.comonly.
On the otherhand,
www2.yourdomain.com/xyz.htmlwill redirect users tohttp://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 www.example.com as separate URLs pointing to two different folders on the server, but make www.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 ^(.*)$ http://www.example.com/$1 [R=301,L]
Just make sure they are added before custom RewriteRule lines are processed for the example.com website if any.
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 www.example.com as deposit content as pdf
Upto this level,it is working fine.
Comments
Post a Comment