Forum Moderators: phranque

Message Too Old, No Replies

Redirect folder / to another .html

         

Buster13

8:12 am on Apr 20, 2010 (gmt 0)

10+ Year Member



i have this url
http://www.example.com/wholesale/

i want it to redirect 301(for SEO purpose) to
http://www.example.com/wholesale/distribution.html

By the way, i have another html,
http://www.example.com/wholesale/catalog.php

currently, it is showing my directory listing which i don't want it to. i know Option -Indexes can prevent from listing but i prefer to 301 redirect.

can someone help?
thanks in advance.

jdMorgan

1:44 pm on Apr 20, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Please review the resources cited in our Apache Forum Charter and our Apache Forum Library. Then post your best-effort code as a basis for discussion.

Thanks,
Jim

Buster13

2:41 pm on Apr 20, 2010 (gmt 0)

10+ Year Member



RewriteRule ^wholesale/$ http://www.example.com/wholesale/distribution.html [L,R=301]

The above works, but I am wondering if there a more 'optimized' way of doing it?

jdMorgan

2:48 pm on Apr 20, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The code looks fine as-is.

For SEO purposes, redirecting to the extensionless URL-path /wholesale-distribution might be more effective. Filetypes on page URLs are neither necessary nor advantageous. But keyword-in-URL is more of an "eye-grabber" thing on search engines which highlight matching words, and not a primary ranking consideration, so it's really more of an SEM thing.

You'll get more --and likely better-- discussion of this topic in our search-engine-specific forums.

Jim

Buster13

5:56 am on Apr 21, 2010 (gmt 0)

10+ Year Member



Thanks for the confirming of my codes.

your suggestion of /wholesale-distribution is nice but i have another catalog.html Therefore i prefer to keep both wholesale related articles(distribution + catalog) under 1 same directory for easier administration.

/wholesale-distribution/
/wholesale-catalog/

VS
(easier to maintain all future wholesale stuffs ;D )
/wholesale/distribution.html
/wholesale/catalog.html

jdMorgan

2:35 pm on Apr 21, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



URLs and filepaths are not the same thing, and need not even be related. URLs are mapped to filepaths by the action of your server, which you can modify with mod_rewrite.

Although it may be more bother than it's worth to you, there is no reason that a requested URL-path of "/wholesale" could not be mapped to a filepath of "/wholesale-distribution.html" while a requested URL-path of "/catalog" is mapped to a filepath of "/wholesale-catalog.html"

"/catalog" and "/wholesale" are extensionless URL-paths, and not file or directory paths of any kind.

The basic function of a server is to "translate" a requested URL to a filepath, and the purpose of HTTP is to eliminate the need for Web clients (e.g. browsers or search engine robots) to know anything about or even care about what your filesystem looks like or how it works under the operating system on your server; URLs and filepaths are two completely different systems for "locating resources."

URLs are used only "out on the Web," while filepaths are used only "inside the server." You can map any URL to any server filepath that you like.

This response is really addressed to all of our readers, since this a major point of confusion among Webmasters, and leads to lots of bad configuration code and many technically-broken and "non-optimally-indexed-and-ranked" sites.

Jim