Forum Moderators: phranque

Message Too Old, No Replies

Redirecting dirextory names to specific page?

         

bambi2000

8:54 pm on Jul 6, 2006 (gmt 0)

10+ Year Member



I have tried browsing through this forum, but haven't found the answer to this one yet:

I have just implemented a new version of our website and have created a .htacces file containing a permanent or gone rule for each page of the old site (all static html files). The new site is implemented using a CMS, so the structure of the URI on the new site is completely different from the old site.

On the old site you automatically got the page www.domain.com/job/index.html whether you wrote:

www.domain.com/job
www.domain.com/job/
www.domain.com/job/index.html

Therefore there are still a lot of pages out there linking directly to for example www.domain.com/job/ or www.domain.com/english/, and they are not redirected to any pages on the new site – they just get a 404.

How can I redirect not only file names but also directory names to specific pages? When writing redirect rules containing just the directory name the contents of the entire subdirectory is redirected which makes absolutely no sense on the new site.

jdMorgan

11:22 pm on Jul 6, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See Apache RedirectMatch [httpd.apache.org], which allows the use of regular expressions rather than simple prefix-matching to determine which URLs to redirect.

Note that using "/" as the "index page" URL is greatly preferable to using "/index.html" because it shortens the URL and hides the site's underlying technology -- which may change again in the future.

Also, be aware that URLs and filepaths are not the same thing, and need not even be related. That is, just because your site is dynamic doesn't mean it has to use query-string-based URLs. Such dynamic URLs, if they contain more than just a few variables, can negatively affect your pages' search engine rankings.

For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim

bambi2000

7:58 pm on Jul 8, 2006 (gmt 0)

10+ Year Member



Thank you for pointing me to the RedirectMatch directive. It seems a simple expression like
/english/?
will do the job.

I thought it was an exact match, but it still allow any string after the match. But at least it doesn't append the rest of the string to the redirected URL. Can I somehow make sure it's an exact match?

jdMorgan

8:04 pm on Jul 8, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See the regular-expressions tutorial cited in our forum charter. You need to start- and end-anchor your pattern.

Jim