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
WSD



Joined: 13 Oct 2010
Posts: 3
Location: Capelle a/d IJssel

PostPosted: Wed 08 Jun '11 14:54    Post subject: RewriteRule question Reply with quote

Can someone help me with the correct code please. This is what I have but it won't work:

Code:
Correct URL requests:
http://www.myserver.nl/myserver/       >  www."myserver".nl   must match with /"myserver"/ = is correct URL!
http://www.myserver.com/myserver/      >  www."myserver".com  must match with /"myserver"/ = is correct URL!
http://www.myserver.nl/myserver/dir/   >  www."myserver".nl   must match with /"myserver"/ = is correct URL!
http://www.myserver.com/myserver/dir/  >  www."myserver".com  must match with /"myserver"/ = is correct URL!

Wrong URL requests:
http://myserver.nl/myserver/       >  "myserver".nl  must match with /"myserver"/  = but correct redirect to: http://www.myserver.nl/myserver/
http://myserver.com/myserver/      >  "myserver".com must match with /"myserver"/  = but correct redirect to: http://www.myserver.com/myserver/
http://myserver.nl/myserver/dir/   >  "myserver".nl  must match with /"myserver"/  = but correct redirect to: http://www.myserver.nl/myserver/dir/
http://myserver.com/myserver/dir/  >  "myserver".com must match with /"myserver"/  = but correct redirect to: http://www.myserver.com/myserver/dir/

Wrong URL requests:
http://www.example.nl/myserver/      >  = must correct redirect to: http://www.myserver.nl/myserver/
http://www.example.nl/myserver/dir/  >  = must correct redirect to: http://www.myserver.nl/myserver/dir/
http://example.nl/myserver/          >  = must correct redirect to: http://www.myserver.nl/myserver/
http://example.nl/myserver/dir/      >  = must correct redirect to: http://www.myserver.nl/myserver/dir/

Wrong URL requests:
http://www.myserver.nl/example/      >  = must correct redirect to: http://www.example.nl/example/
http://www.myserver.nl/example/dir/  >  = must correct redirect to: http://www.example.nl/example/dir/
http://myserver.nl/example/          >  = must correct redirect to: http://www.example.nl/example/
http://myserver.nl/example/dir/      >  = must correct redirect to: http://www.example.nl/example/dir/


Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^myserver\.nl$ [OR]
RewriteCond %{HTTP_HOST} ^www\.myserver\.nl$ [OR]
RewriteCond %{HTTP_HOST} ^myserver\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.myserver\.com$
RewriteCond %{REQUEST_URI} !^/myserver/
RewriteRule ^(.*)$ http://www.myserver.nl/myserver/$1 [R=301,L]
Back to top
bagu



Joined: 06 Jan 2011
Posts: 193
Location: France

PostPosted: Thu 09 Jun '11 12:27    Post subject: Reply with quote

The folowing work :
Code:
   RewriteEngine on
   RewriteCond %{HTTP_HOST}   ^something.net [NC]
   RewriteRule ^(.*)         http://www.something.net$1 [R=301,L]


Hope it can help.
Back to top
WSD



Joined: 13 Oct 2010
Posts: 3
Location: Capelle a/d IJssel

PostPosted: Thu 09 Jun '11 14:06    Post subject: Dont'work Reply with quote

Sorry, doesn't work....

Can someone tell me the code when the
host http://myserver.nl or http://www.myserver.nl
doesn't match with the path /myserver/
please....

THX
Back to top
James Blond
Moderator


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

PostPosted: Thu 09 Jun '11 17:46    Post subject: Reply with quote

For me this works

Code:

RewriteEngine On

RewriteBase /

RewriteCond %{HTTP_HOST} !^www\.myserver\.nl$ [NC]
RewriteRule ^(.*)$ http://wwwmyserver.nl/$1 [R=301,L]

Back to top


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