"example.com" forwards to "www.example.com", but "example.com/file.pdf" just forwards to "www.example.com". How to fix?

"example.com" forwards to "www.example.com", but "example.com/file.pdf" just forwards to "www.example.com". How to fix? - If a page has internal and external outgoing links to redirecting URLs, it’s returning 3xx (301, 302, etc.) HTTP status codes standing for redirection. This issue means that the page does not exist on a permanent or temporary basis. It appears on most of the popular web browsers, usually caused by a misconfigured website. However, there are some steps you can take to ensure the issue isn’t on your side. You can find more details about redirecting URLs by reading the Google Search Central overview. In this article, we’ll go over how you can fix the "example.com" forwards to "www.example.com", but "example.com/file.pdf" just forwards to "www.example.com". How to fix? error on your web browser. Problem :


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

Solution :

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.com will not pass values to the destination URL so, www1.yourdomain.com/xyz.html will redirect users to http://destination.com only.



On the otherhand, www2.yourdomain.com/xyz.html will redirect users to http://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.


We hope that this article has helped you resolve the web-hosting, redirects, domain-forwarding error in your web browsers. Enjoy browsing the internet uninterrupted!

Comments

Popular posts from this blog

How to redirect to any domain [duplicate]

"302 found" for index page bad for SEO?

Create redirect from url like www.example.us/?p=100&option=