|
Author: niewczyk
Date: 27-07-07 21:48
I'm new to using RewriteRule. I've a problem. I need to rewrite some URL's under https and some back under http. I have no problem with the rewrite to https:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule /user http://%{HTTP_HOST}%{REQUEST_URI} [L]
However, I don't know how to write a RewriteRule from HTTPS to HTTP.
Everthing I try leads me no where.
I'm confused at all the samples I've seen so. Is the someone that could help or point me in the right direction.
|
|
Reply To This Message
|
|
Author: Dan
Date: 28-07-07 14:52
This might help.
You can get to this website through http://freebsddiary.org/ and http://www.freebsddiary.org/ but if you use the former, you are directed to the latter. This redirect is accomplished with the following directives in httpd.conf:
<VirtualHost *>
ServerName freebsddiary.org
Redirect permanent http://www.freebsddiary.org/
</VirtualHost>
Does that give you any ideas? It's not mod_rewrite, but it does what you want.
--
Webmaster
|
|
Reply To This Message
|
|
Author: niewczyk
Date: 30-07-07 13:18
Dan,
Thanks for your reply. I do indeed appreciate your time and suggestions. I tried the "Redirect permanent" statement you suggested. However, server complained that"
"Starting httpd: Syntax error on line 31 of /etc/httpd/conf.d/httpd.conf:
URL to redirect to is missing
[FAILED]"
So then I added the "/" then "/index" for the directory to look for.
Redirect permanent / http://www.mysite.org/
Redirect permanent /index http://www.mysite.org/
The results were that index page never loaded.
Also, according to the initial artice I read on http://www.freebsddiary.org/
wouldn't the Redirect permanent be a major peformance hit?
The website I work on is a heavy traffic site.
Redirects vs rewrites
When should you use a redirect? When should you use a rewrite? If the file is on the same website, you should use a rewrite. If the file is on another server, you should use a redirect. Why? A simple answer is bandwidth. A redirect sends the new URL back to the client and the client must reissue the URL request, which creates more traffic. With a rewrite, the original request is satisfied and a new URL is returned along with the new file. The client does not have to reissue anything.
|
|
Reply To This Message
|
|
Author: Dan
Date: 30-07-07 13:27
niewczyk wrote:
> Dan,
>
> Thanks for your reply. I do indeed appreciate your time and
> suggestions. I tried the "Redirect permanent" statement you
> suggested. However, server complained that"
>
> "Starting httpd: Syntax error on line 31 of
> /etc/httpd/conf.d/httpd.conf:
> URL to redirect to is missing
> [FAILED]"
It appears you are not using FreeBSD there....
> So then I added the "/" then "/index" for the directory to look
> for.
>
> Redirect permanent / http://www.mysite.org/
> Redirect permanent /index http://www.mysite.org/
I expected to see https there, not http.
> The results were that index page never loaded.
>
> Also, according to the initial artice I read on
> http://www.freebsddiary.org/
> wouldn't the Redirect permanent be a major peformance hit?
I guess you have to define major....
AFAIK, you don't want any traffic on http. You want it all on https. Correct?
> The website I work on is a heavy traffic site.
>
> Redirects vs rewrites
> When should you use a redirect? When should you use a rewrite?
> If the file is on the same website, you should use a rewrite.
> If the file is on another server, you should use a redirect.
> Why? A simple answer is bandwidth. A redirect sends the new
> URL back to the client and the client must reissue the URL
> request, which creates more traffic. With a rewrite, the
> original request is satisfied and a new URL is returned along
> with the new file. The client does not have to reissue
> anything.
https is another website. It is not the same website as http.
--
Webmaster
|
|
Reply To This Message
|
|
Author: niewczyk
Date: 30-07-07 14:13
First I'm sorry for any misunderstanding. I keep forgetting that all the flavors of unix don't act the same way for every command. I thought apache was all the same but seems as it is not. I'm running Red Hat Enterprise Linux ES release 4 (Nahant Update 4).
I've also posted my question to a www.webmasterworld.com
Haven't received a response yet.
I need to rewrite 6 URL's to https and the rest to http.
I can rewite the URL to https fine via:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule /user http://%{HTTP_HOST}%{REQUEST_URI} [L]
However, I don't know how to write a RewriteRule from HTTPS to HTTP.
Everthing I try fails.
Dave
|
|
Reply To This Message
|
|