Link to home
Start Free TrialLog in
Avatar of jamie_2008
jamie_2008

asked on

.htaccess problem in https

i have setup https on my website.  by using this code

RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://www.cvbroadcaster.com/$1 [R]

i want to redirect this page to not https .

https://www.cvbroadcaster.com/cv_database/cv_list.php 
to
http://www.cvbroadcaster.com/cv_database/cv_list.php 



i have also another page to not g oto https ..just http . so what will be its rule ?
Avatar of caterham_www
caterham_www
Flag of Germany image

> i have also another page to not g oto https ..just http . so what will be its rule ?
Add anoter condition to the first rule in order to prevent a redirect to https
RewriteEngine on
RewriteCond %{HTTPS} =off
# exclude /cv_database/cv_list.php
RewriteCond %{REQUEST_URI} !=/cv_database/cv_list.php
RewriteRule ^(.*)$ https://www.cvbroadcaster.com/$1 [R,L]
 
# https://www.cvbroadcaster.com/cv_database/cv_list.php --> http://www.cvbroadcaster.com/cv_database/cv_list.php 
RewriteCond %{HTTPS} =on
RewriteRule ^(cv_database/cv_list\.php)$ http://www.cvbroadcaster.com/$1 [R,L]

Open in new window

Avatar of jamie_2008
jamie_2008

ASKER

@caterham_www:

what if i want to add 2 more url's to exclude ?

above is working fine for 1 url

thanks
Just add more conditions like
RewriteCond %{HTTPS} =off
# exclude /cv_database/cv_list.php
RewriteCond %{REQUEST_URI} !=/cv_database/cv_list.php
RewriteCond %{REQUEST_URI} !=/other_url-path
RewriteCond %{REQUEST_URI} !=/an_other_one
RewriteRule ^(.*)$ https://www.cvbroadcaster.com/$1 [R,L]

Open in new window

> i want to redirect this page to not https
RewriteCond %{HTTPS} =on
RewriteCond %{REQUEST_URI} !/cv_database/cv_list.php$
RewriteRule ^(.*)$ http://www.cvbroadcaster.com/$1 [R,L]
i added in this way ..but not worked ..

it says ..redirect loop ..so it will not complete
RewriteEngine on
RewriteCond %{HTTPS} =off
# exclude /cv_database/cv_list.php
RewriteCond %{REQUEST_URI} !=/cv_database/cv_list.php
RewriteCond %{REQUEST_URI} !=/cv_database/free_cv_database.php
RewriteCond %{REQUEST_URI} !=/cv_distribution/cv_sending.php
RewriteRule ^(.*)$ https://www.cvbroadcaster.com/$1 [R,L]
 
# https://www.cvbroadcaster.com/cv_database/cv_list.php --> http://www.cvbroadcaster.com/cv_database/cv_list.php 
RewriteCond %{HTTPS} =on
RewriteRule ^(cv_database/cv_list\.php)$ http://www.cvbroadcaster.com/$1 [R,L]
RewriteRule ^(cv_database/free_cv_database\.php)$ http://www.cvbroadcaster.com/$1 [R]
RewriteRule ^(cv_distribution/cv_sending\.php)$ http://www.cvbroadcaster.com/$1 [R]

Open in new window

this is my all .htaccess file ... please look at that
# -FrontPage-
 
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
RewriteEngine On
RewriteRule ^cv_broadcasting\.html$ /cv_broadcasting.php
 
RewriteEngine on
RewriteCond %{HTTPS} =off
# exclude /cv_database/cv_list.php
RewriteCond %{REQUEST_URI} !=/cv_database/cv_list.php
RewriteCond %{REQUEST_URI} !=/cv_database/free_cv_database.php
RewriteCond %{REQUEST_URI} !=/cv_distribution/cv_sending.php
RewriteRule ^(.*)$ https://www.cvbroadcaster.com/$1 [R,L]
 
# https://www.cvbroadcaster.com/cv_database/cv_list.php --> http://www.cvbroadcaster.com/cv_database/cv_list.php 
RewriteCond %{HTTPS} =on
RewriteRule ^(cv_database/cv_list\.php)$ http://www.cvbroadcaster.com/$1 [R,L]
#RewriteRule ^(cv_database/free_cv_database\.php)$ http://www.cvbroadcaster.com/$1 [R]
#RewriteRule ^(cv_distribution/cv_sending\.php)$ http://www.cvbroadcaster.com/$1 [R]
 
#RewriteCond %{SERVER_PORT} !^443$
 
#RewriteRule ^(.*)$ https://www.cvbroadcaster.com/$1 [R]
 
AddType x-mapp-php5 .php
 
 
ErrorDocument 400 error400.html
ErrorDocument 403 error403.html
ErrorDocument 404 error404.html
ErrorDocument 500 error500.html

Open in new window

change the last one into
RewriteCond %{HTTPS} =on
RewriteRule ^(cv_database/cv_(list|database|sending)\.php)$ http://www.cvbroadcaster.com/$1 [R,L]

Open in new window

i have 2 files in a cv_database folder and one in cv_distribution folder .


RewriteEngine on
RewriteCond %{HTTPS} =off
# exclude /cv_database/cv_list.php
RewriteCond %{REQUEST_URI} !=/cv_database/cv_list.php
RewriteCond %{REQUEST_URI} !=/cv_database/free_cv_database.php
RewriteCond %{REQUEST_URI} !=/cv_distribution/cv_sending.php
RewriteRule ^(.*)$ https://www.cvbroadcaster.com/$1 [R,L]
 
# https://www.cvbroadcaster.com/cv_database/cv_list.php --> http://www.cvbroadcaster.com/cv_database/cv_list.php 
RewriteCond %{HTTPS} =on
RewriteRule ^(cv_database/cv_list\.php)$ http://www.cvbroadcaster.com/$1 [R,L]
RewriteRule ^(cv_database/free_cv_database\.php)$ http://www.cvbroadcaster.com/$1 [R]
RewriteRule ^(cv_distribution/cv_sending\.php)$ http://www.cvbroadcaster.com/$1 [R]

Open in new window

hey
      its working ....i made the change ..below is the code

but can  u tell me why following was not working ?

RewriteRule ^(cv_database/cv_list\.php)$ http://www.cvbroadcaster.com/$1 [R,L]
RewriteRule ^(cv_database/free_cv_database\.php)$ http://www.cvbroadcaster.com/$1 [R]
RewriteRule ^(cv_distribution/cv_sending\.php)$ http://www.cvbroadcaster.com/$1 [R]

RewriteRule ^(cv_(database|distribution)/cv_(list|database|sending)\.php)$ http://www.cvbroadcaster.com/$1 [R,L] 

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of caterham_www
caterham_www
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial