Then it loops through & if it finds a match, it redirects the page appropriately. If there is no match and the uri does not start with any of the strings listed, it will redirect you to another A page. If the conditions are not met, go to the index page.
The problem lies in my first set of rules, namely SSL and & is off. I want to specify that the uri must be started as an administrator or in a secure way .But if I add ^ to the beginning of the string, everything will break. This is what I have:
RewriteCond %{HTTPS} off
RewriteCond% {REQUEST_URI} ^/?(admin|secure)
RewriteRule ^(.*)$https://%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{ HTTPS} on
RewriteCond %{REQUEST_URI} !^/?(admin|secure)
RewriteRule ^(.*)$http://%{HTTP_HOST}/$1 [R=301,L]< br />
...specific rewrites here
RewriteRule ^secure-form1$secure/contract/secure-form1 [L]
RewriteRule ^secure$secure/article/secure [L]< br />
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteCond %{REQUEST_URI} !^/(admin|form|secure|page)/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$index.php/page/article/$1 [L]
RewriteCon d %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$index.php/$1 [L]
If I will ^ The symbol remains in the first 2 rewrite conditions (https on& off) and then
http://www.example.com/secure
is rewritten to
https://www.example.com/index. php/secure/article/secure
This is the last rewrite rule. The URL is actually changed to this in the browser.
If I take out the ^ symbol from the first two rewrite conditions, Then it will go to the right page. But I do need to specify the beginning of the uri because there are other pages in the middle of the uri (and after the slash) that have “secure” and should not use SSL.
I Can’t come up with this.
< /p>
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(.*)$
RewriteRule ^/?(admin|secure)$https://%1/$1 [ R=301,L]
I am using codeigniter to build a site. I have a series of rewrite conditions & rules in the .htaccess file. The first set of rules is based on the uri The first paragraph turns on or off SSL.
Then it loops through & if it finds a match, it redirects the page appropriately. If there is no match, and the uri does not end with any string listed At the beginning, you will be redirected to another page. If the conditions are not met, then go to the index page.
The problem is with my first set of rules, that is, SSL and & are off. I think Specifying the uri must start in an administrator or safe way. But if I add ^ to the beginning of the string, everything will break. This is what I have:
RewriteCond% {HTTPS} off
RewriteCond %{REQUEST_URI} ^/?(admin|secure)
RewriteRule ^ (.*)$https://%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/?( admin|secure)
RewriteRule ^(.*)$http://%{HTTP_HOST}/$1 [R=301,L]
...specific rewrites here
RewriteRule ^secure-form1$secure/contract/secure-form1 [L]
RewriteRule ^secure$secure/article/secure [L]
RewriteCond %{HTTP_HOST} ^www.example. com$
RewriteCond %{REQUEST_URI} !^/(admin|form|secure|page)/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$index.php/page/article/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d< br />RewriteRule ^(.*)$index.php/$1 [L]
If I keep the ^ symbol in the first 2 rewrite conditions (https on& off) then
http:/ /www.example.com/secure
Rewrite to
https://www.example.com/index.php/secure/article/secure
This is the last rewrite rule. This URL is actually Change to this in the browser.
If I take out the ^ symbol from the first two rewrite conditions, then it will go to the right page. But I do need to specify the beginning of the uri, because in the uri There are other pages in the middle (and after the slash) that have “secure” and should not use SSL.
I can’t figure this out.
Try this:
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(.*)$
RewriteRule ^/?(admin|secure)$https://%1/$1 [R=301,L]