logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: RewriteRule question
Author
tbirnseth



Joined: 20 Sep 2012
Posts: 2

PostPosted: Thu 20 Sep '12 1:34    Post subject: RewriteRule question Reply with quote

I have a problem with a rewrite rule.
RewriteRule ^Diet\ Plans(.*)$ http://dietplans.xx.com$1 [R=301,L]

I want any reference to the "Diet Plans" directory to redirect to dietplans.xx.com.
this is working okay.

I want any reference to a file/directory in the "Diet Plans" directory to redirect to that directory/file at the new server. I.e. a reference from
abc.com/Diet Plans/xyz.html

should redirect to
dietplans.xx.com/xyz.html

However, it goes to the document root of the new server rather than maintaining the URI. I.e. dietplans.xx.com/

Can anyone identify what I've done wrong?

Appreciate any help you can provide.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Sat 22 Sep '12 23:01    Post subject: Reply with quote

Untested but should work.
Code:

^/Diet\ Plans/([a-z0-9_-]+)/$ http://dietplans.xx.com/$1 [R=301,L]
Back to top
tbirnseth



Joined: 20 Sep 2012
Posts: 2

PostPosted: Sun 23 Sep '12 0:32    Post subject: Reply with quote

Hmm... Can understand the leading '/', but both a leading and trailing '/' outside the character set?

Any clue why my '(.*)' doesn't get substituted into $1?

I'd think I'd have to add a '/' into the character set to match Diet Plans/sub1/sub2/file.txt so the redirect would become
dietplans.xx.com/sub2/sub2/file.txt

Right?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Tue 25 Sep '12 14:14    Post subject: Reply with quote

You are right with the starting '/' I missed the part of anywhere in the url.
Back to top


Reply to topic   Topic: RewriteRule question View previous topic :: View next topic
Post new topic   Forum Index -> Apache