Forum Moderators: phranque

Message Too Old, No Replies

How do I send all requests to the root domain?

         

DiscoStu

3:47 am on Jan 31, 2011 (gmt 0)

10+ Year Member



I want to send requests for existing URLs to the homepage (www.domain.com/), and give a 404 for requests for non existing urls. Is there a way to this?

jdMorgan

3:20 am on Feb 1, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



List all URLs that you want to redirect, or
List all URLs that you do not want to redirect, or
Commit to never removing the 'files' that correspond(ed) to the URLs that you want to redirect.

If one of those options is chosen, then it is possible to code a solution. Be careful to fully weigh the impact that each has on the potential for growing your site and upon the on-going, long-term maintenance of this code and your site.

None of these options are "nice," but you may find that one of them is "less not-nice" than the others for your site.

BTW, watch the terminology: A URL exists as soon as anyone, anywhere links to it. It does not matter whether the URL resolves to an existing file or script on an existing server on an existing domain: The URL is a valid URL as soon as it is linked.

This URL-versus-file distinction may make it easier to understand why your problem is difficult to solve: You state that you want to redirect or rewrite all requests for (all URLs which resolve to existing files) to your homepage, and you want request for (all URLs that do not resolve to existing files) to go 404. Simple enough, but you can't then delete the now-redirected-URLs' files and have this still work unless you first list out one URL-set or the other (i.e. a redirect list or a 404 list) in the code...

Jim