Forum Moderators: phranque

Message Too Old, No Replies

.htaccess Redirection of nonexistent directories?

Can I pick up standard directory names and redirect, e.g. gallery, links

         

Barton68

4:53 pm on Jul 16, 2010 (gmt 0)

10+ Year Member



Hi,

is it possible to redirect from a directory reference that does not exist.

If a user enters the following:
http://www.****.com/gallery/ a redirection to http://www.****.com/my-specific-gallery/


Thank you.

jdMorgan

1:28 am on Jul 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, because a URL is created and exists from the moment it is referenced (e.g. linked-to) on the Web. It is up to the server to resolve that URL (or not) to a resource, which is usually a file within the server, but not necessarily.

See Apache mod_rewrite for most applications. This specific application does not necessarily call for a redirect. You may actually want to use an internal rewrite and map the URL example.com/gallery/pic to the internal server filepath /my-specific-gallery/pic -- Note that URLs and filepaths are not at all the same thing, nor even necessarily related. URLs are only 'associated' with files through the action of a Web server. It really helps to understand this fact from the outset.

As an example, none of the URLs that you see in your address bar on this site actually resolve to existing .htm files. In actuality, there are no .htm files, because the pages are generated by a script. And nevertheless, the URLs are perfectly valid.

Jim

Barton68

2:05 pm on Jul 19, 2010 (gmt 0)

10+ Year Member



Thank you again, very useful.