Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite to external address

Apache mod_rewrite

         

apthorburn

5:10 pm on Oct 11, 2007 (gmt 0)

10+ Year Member



Hi,

We have a couple members of staff who used to have CV information on our external site, they are about to leave our employment and wish their staff info pages to be forwarded to their new location.

I have had a good look at mod_rewrite and I am stumped. I think I am following things correctly, but the end result fails.

I have also tried Redirects and RedirectMatches, but to no avail!

I would like this page:

http://www.example.uk/staff/staffdetails.php?lstaffer-name

to be redirected to this new web site:

http://www.staffer-name.com/

Any pointers would be great.

Thanks in advance

Andrew

[edited by: jdMorgan at 6:20 pm (utc) on Oct. 11, 2007]
[edit reason] No URLs or personally-identifiable info, please. [/edit]

jdMorgan

6:24 pm on Oct 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The concept is backwards: You can't "forward a page" you can only redirect a request for a URL. As such, what they need os to allow their own sites' URLs to redirect to your staff-info pages -- The host to which a client request is made must do the redirect.

Easiest solution would be to copy your staff info pages and e-mail them to them. Then they can host it as they please.

Jim

apthorburn

7:56 pm on Oct 11, 2007 (gmt 0)

10+ Year Member



Hi,

Thanks for the quick response. Their website is entirely different to our and I think that they just wish it to be redirected. I may have asked my question in the wrong section of the forums?

I'll also make sure not to include personal information in future posts.

Thanks again

Andrew

g1smd

12:01 am on Oct 12, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This should be easy.

RewriteRule /the.old.one.html http://www.domain.com/ [R=301,L]

The R=301 ensures a redirect instead of a rewrite.

.

Oh heck, is the parameter for that particular staff member? You'll maybe need something like this first:

RewriteCond {QUERY_STRING} staffer-name

apthorburn

8:02 am on Oct 12, 2007 (gmt 0)

10+ Year Member



Hi,

Thanks for the pointer, the query string thing is for a particular member of staff. I think I tried that permutation, but my brain was getting a bit addled.

I shall try this and see what happens.

Thanks again, and have a good weekend.

Andrew

g1smd

12:37 am on Oct 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Typo in MY code!

The URL seen by RewriteRule will NOT have a leading / on it.

Remove the leading / from the file path in that line.

jdMorgan

12:57 am on Oct 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Missing "%" and literal period escaping:

RewriteCond %{QUERY_STRING} staffer-name
RewriteRule ^staff/staffdetails\.php$ http://www.staffer-name.com/ [R=301,L]

Jim

apthorburn

10:47 am on Oct 15, 2007 (gmt 0)

10+ Year Member



Jim,

Many thanks for the solution. It worked and I now have a happy member of staff!

I am going to print this thread out and stick it somewhere really obvious....

Thanks again for the help; maybe now I'll be able to make sense of the mod_rewrite examples.

Best wishes

Andrew

g1smd

8:11 pm on Oct 15, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Note to self. Don't answer forum posts after midnight, when you're already really tired.

Apologies for the couple of typos.