Forum Moderators: phranque

Message Too Old, No Replies

https:// and http:// redirect

https:// and http:// redirect

         

rednokes

8:17 am on Sep 24, 2007 (gmt 0)

10+ Year Member



Hello I am trying to make : [example.co.uk...] and http://example.co.uk both redirect to http://www.example.co.uk/section/new.aspx

but with no luck - i am using

RewriteCond Host: (?:www\.)?example\.co\.uk
RewriteRule (.*) http\://www\.example\.co\.uk/section/new\.aspx$1 [I,RP,L]

thanks

[edited by: jdMorgan at 12:52 pm (utc) on Sep. 25, 2007]
[edit reason] example.co.uk [/edit]

jdMorgan

9:57 pm on Sep 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you on Apache or Microsoft IIS? -- The code you posted looks like IIS ISAPI Rewrite, not Apache mod_rewrite.

On Apache, a solution would be:


# Redirect http://example.co.uk/<xyz> or https://example.co.uk/<xyz> [b]-OR-[/b]
RewriteCond %{HTTP_HOST} ^example\.co\.uk [OR]
# Redirect htt[b]ps[/b]://[b]www.[/b]example.co.uk/<xyz>
RewriteCond %{SERVER_PORT}<->%{HTTP_HOST} ^443<->www\.example.co\.uk
# to http://www.example.co.uk/section/new\.aspx?page=<xyz>
RewriteRule (.*) http://www.example.co.uk/section/new\.aspx?page=$1 [R=301,L]

Note that although I use "<->" to imply concatenation, these characters are simply arbitrary "boundary markers" between the combined variable values. I am not sure if a similar construct is available in ISAPI Rewrite.

This code assumes that all protocol and domain variants resolve to the same directory -- the directory where this code is installed in .htaccess.

Also, I wasn't sure what you intended to do with the requested URL-path -- the "page" path, that is. I attached it as a query string name/value pair, "page=<xyz>", just for an example.

Jim

rednokes

8:34 am on Sep 25, 2007 (gmt 0)

10+ Year Member



hi no luck still

a typical example of something my redirect file is:

RewriteCond Host: ^example\.com
RewriteRule (.*) http\://www\.example\.co\.uk/mysite/s1Home\.aspx$1 [I,RP]

so i dont think
RewriteCond %{HTTP_HOST} ^example\.co\.uk [OR]

is the correct syntax

i just tried

# Redirect http://example.co.uk/<xyz> or [example.co.uk...] -OR-
RewriteCond Host: ^example\.co\.uk [OR]
# Redirect [example.co.uk...]
RewriteCond SERVER_PORT<->HTTP_HOST ^443<->www\.example.co\.uk
# to http://www.example.co.uk/section/new\.iVillageHome?page=<xyz>
RewriteRule (.*) http://www.example.co.uk/iVillage/iVillageHome\.aspx?page=$1 [R=301,L]

[edited by: jdMorgan at 12:50 pm (utc) on Sep. 25, 2007]
[edit reason] example.com [/edit]