Forum Moderators: phranque

Message Too Old, No Replies

Help with .htaccess

want to go from secure to non secure area

         

frediutah

8:34 pm on Oct 14, 2010 (gmt 0)

10+ Year Member



I am dealing with a problem with joomla.
I have to use my module that collect forms using SSL so when the user clicks on home then should be http

I found out that .htaccess will be useful for this but I am not very literate in this arena...

Basically this is what I need.

go from:

[atpcpa.com...]

to

http://atpcpa.com/index.php?option=com_content&view=frontpage&Itemid=1

I cannot figure this out using .htaccess since it contains get vars in the name and my few knowledge of .htaccess does not help

thanks in advance for any help to everybody...

[edited by: jdMorgan at 7:06 pm (utc) on Oct 15, 2010]
[edit reason] De-linked URLs for readability. [/edit]

dave_c00

10:35 am on Oct 15, 2010 (gmt 0)

10+ Year Member



Have a look at the following. [webmasterworld.com...]

frediutah

6:18 pm on Oct 16, 2010 (gmt 0)

10+ Year Member



Thanks Dave, but your example talks about sites that are
[yourdomain.com...]

in my case will be

[mydomain...] etc....

so my question is how do i read those get variables so redirection can be done depending on it.

I just need one rule If somebody wants to write it for me it will save me lot of time....
Thanks!

frediutah

9:28 pm on Oct 16, 2010 (gmt 0)

10+ Year Member



Thanks everybody. I got the answer for this incident....

I will post the solution since it will be useful for somebody else.

Example:
If trying to access from 1https:/mydomain.com/option=com_content&view=frontpage&Itemid=1 then it will be redirected to http
RewriteCond %{SERVER_PORT} 443
RewriteCond %{QUERY_STRING} option=com_content&view=frontpage&Itemid=1 [NC]
RewriteRule (.*) 1http://mydomain.com/$1 [R=301]


this is the opposite if coming from http then it will be redirected to https
eg: 1http://myserver.com/option=com_brief&Itemid=93

RewriteCond %{SERVER_PORT} 80
RewriteCond %{QUERY_STRING} option=com_brief&Itemid=93 [NC]
RewriteRule (.*) [myserver.com...] [R=301]

g1smd

9:44 pm on Oct 16, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Don't forget to add the [L] flag to both rules.

frediutah

9:49 pm on Oct 16, 2010 (gmt 0)

10+ Year Member



I am really newby to htaccess

Thanks!

frediutah

9:56 pm on Oct 16, 2010 (gmt 0)

10+ Year Member



Thanks again to g1smd

Adding L means this is the last rule of the set. (I explain this just in case another newby like me read this.

so finally the rules looks like this:

If trying to access from 1https:/mydomain.com/option=com_content&view=frontpage&Itemid=1 then it will be redirected to http
RewriteCond %{SERVER_PORT} 443
RewriteCond %{QUERY_STRING} option=com_content&view=frontpage&Itemid=1 [NC]
RewriteRule (.*) 1http://mydomain.com/$1 [R=301,L]


this is the opposite if coming from http then it will be redirected to https
eg: 1http://myserver.com/option=com_brief&Itemid=93

RewriteCond %{SERVER_PORT} 80
RewriteCond %{QUERY_STRING} option=com_brief&Itemid=93 [NC]
RewriteRule (.*) [myserver.com...] [R=301,L]


And this is the final version.
Thanks everybody!
It is implemented in my site and I am very happy with this Forum it took me less than 24 hrs to get it going thanks to all of you folks!

jdMorgan

7:28 pm on Oct 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> Adding L means this is the last rule of the set. (I explain this just in case another newby like me read this.

No, it means "If this rule is invoked, stop processing rewriterules for this pass through the .htaccess file." If the rule is not invoked, it has no effect, and processing continues with the next rule.

That code has typos and omissions in it. Cleaned up, it will be:

RewriteCond %{SERVER_PORT} =443
RewriteCond %{QUERY_STRING} ^option=com_content&view=frontpage&Itemid=1$ [NC]
RewriteRule ^(.*)$ http://mydomain.com/$1 [R=301,L]
#
RewriteCond %{SERVER_PORT} =80
RewriteCond %{QUERY_STRING} ^option=com_brief&Itemid=93$ [NC]
RewriteRule ^(.*)$ https://myserver.com/$1 [R=301,L]

Notice that this code should not be used to 'cover up' errors in the links on your pages. They should be used only to correct search engine listings showing the incorrect protocol because of incorrect links to your pages from other sites. Correct the links on your pages so that neither of these two rules will be invoked because of linking errors on your site.

Simply put, rewrite code should not be used to cover up your own linking errors, only to speed up correction of the damage that they cause to your search results and to correct linking errors on other Web sites.

Jim