Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
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.
| |
|
Topic: RewriteRule question |
|
Author |
|
tbirnseth
Joined: 20 Sep 2012 Posts: 2
|
Posted: Thu 20 Sep '12 1:34 Post subject: RewriteRule question |
|
|
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
|
Posted: Sat 22 Sep '12 23:01 Post subject: |
|
|
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
|
Posted: Sun 23 Sep '12 0:32 Post subject: |
|
|
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
|
Posted: Tue 25 Sep '12 14:14 Post subject: |
|
|
You are right with the starting '/' I missed the part of anywhere in the url. |
|
Back to top |
|
|
|
|
|
|