Forum Moderators: phranque

Message Too Old, No Replies

Folder Redirect - Redirect 301 or Mod_rewrite?

Hit by spam changing bb system.

         

XtendScott

10:54 pm on Jul 14, 2004 (gmt 0)

10+ Year Member



I have setup a Redirect 301 /foldername/page.htm ht**://www.mydomain.com/newfolder/index.php.

But Redirect 301 /foldername/ ht**://www.mydomain.com/newfolder/index.php for the whole folder it adds the requested page name to the end of the redirect as ...index.phpoldpage.htm and I get a 404.

I guess it is expecting a folder with same page names.

How could I do a mod_rewrite to do the same or Redirect 301 work with a bit of modification to the above?
Basically killing the folder and redirecting all the pages to the newfolder/index.php

Help!

jdMorgan

5:08 am on Jul 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That's how it works. Redirect uses prefix-matching, and copies any unmatched portion of the requested URL to the end of the substitution URL. You'll need to use RedirectMatch instead of Redirect. See the Apache mod_alias documentation [httpd.apache.org].

Jim

XtendScott

6:23 am on Jul 15, 2004 (gmt 0)

10+ Year Member



This is what I have found that seems to be working.

It could probably use a bit of tweeking.

RewriteEngine On
Options +followsymlinks
RewriteBase /

# rewrite Begin
RewriteRule ^myfolder/.* htt*://www.my-domain.com/phpBB/index.php [R=301,L]

Or should I use:
RedirectMatch permanent myfolder/.* htt*://www.my-domain.com/phpbb/index.php

Getting the subfolders and files is the main issue. Is one way or the other preferred?

fyi: * in http to prevent link.

jdMorgan

3:42 pm on Jul 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Either way is fine, they do the same thing.
You can leave the ".*" off the the end of the patterns. As long as the pattern is not end-anchored, the ".*" at the end is redundant.

[added] A "style" note: The Options directive should be placed before the RewriteEngine on directive. [/added]

Jim