Forum Moderators: phranque

Message Too Old, No Replies

Advanced rewrite rules

Advanced rewrite rules

         

Merlin2000

1:28 am on Apr 17, 2005 (gmt 0)

10+ Year Member


After inserting this into my .htaccess for http://www.domain.com/secure/.htaccess

RewriteEngine On
RewriteCond %{SERVER_PORT}!^443$ [OR]
RewriteCond %{HTTP_HOST}!^www\.domain\.com [NC]
RewriteRule ^(.*)$ https://www.domain.com/secure/$1 [R,L]

I goto http://www.domain.com/secure/ and it takes me to https://www.domain.com/secure/

However, when I go to http://www.domain.com/secure

It redirects me to https://www.domain.com/secure//home/username/public_html/secure

Also, when I goto http://www.domain.com/secure/anotherpage

It takes me to https://www.domain.com/secure/anotherpage
which is correct.

I basically want to make all URLs on the /secure folder to use https instead of http.

--
Also, I would like to make a condition, where when the address is http://www.domain.com/secure/another-page-thats-not-secure.php to not rewrite to https

This is just one page that needs to be unsecure.

claus

1:43 am on Apr 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The URL without the trailing slash will not be caught by the
.htaccess
file inside the folder with the trailing slash.

You will need an additional

.htaccess
file outside the folder /secure/ to catch requests for that folder without the trailling slash, as without the trailing slash the web server will probably not look inside that folder at all.

Hope this is clear... Otherwise i'll try an example:

Requests for

example.com/secure/
example.com/secure/something
example.com/secure/something-else
- etc.

will be catched by the

.htaccess
file inside the folder "/secure/". A request like this, without the trailing slash:

example.com/secure

- is not a request for the folder, but for the filename "secure" which is something else. As that filename does not exist Apache tries to find the closest match, which is the long path you have seen.

So to rewrite from A to B:

A) example.com/secure
B) example.com/secure/

- you will need an

.htaccess
file placed one level up from the folder "/secure/", like this:

example.com/.htaccess

Merlin2000

1:47 am on Apr 17, 2005 (gmt 0)

10+ Year Member



Thanks for the reply claus,

What code should I use in the .htaccess file if it is going to be placed outside the /secure folder?

Also, I would like to make a condition, where when the address is [domain.com...] to not rewrite to https

This is just one page that needs to be unsecure.

claus

1:57 am on Apr 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>> what rule

I think this one-liner will do the trick, but do test it:

-----------------------------------------

RewriteRule ^secure$ [domain.com...]  [R=301,L]

-----------------------------------------

>> not secure

You current rule should be modified like this, but do test:

-----------------------------------------

RewriteEngine On 
RewriteCond %{SERVER_PORT}!^443$ [OR]
RewriteCond %{HTTP_HOST}!^www\.domain\.com [NC]
RewriteRule ^([^secure/another-page-thats-not-secure.php])$ [domain.com...] [R=301,L]

-----------------------------------------

Another way of writing it is this, perhaps that syntax is easier, plus it will allow you to exclude more than one URL if you should get the need:

-----------------------------------------

RewriteEngine On 
RewriteCond %{REQUEST_URI} !^/secure/another-page-thats-not-secure.php
RewriteCond %{SERVER_PORT} !^443$ [OR]
RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301,L]

-----------------------------------------

Two URL's excluded:

-----------------------------------------

RewriteEngine On 
RewriteCond %{REQUEST_URI} !^/secure/another-page-thats-not-secure.php [OR]
RewriteCond %{REQUEST_URI} !^/secure/yet-another-page-thats-not-secure.php
RewriteCond %{SERVER_PORT} !^443$ [OR]
RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301,L]

-----------------------------------------

I took the liberty of changing your R flags to R=301, that way the browser address bar will also display the change.



Added:
I'm not sure about the effect of your second rewrite rule - doesn't this mean that requests with www will not get forwarded to "https"?

Ie:

http //www.example.com

- will not get forwarded to

httpS //www.example.com

(unless it's on port 443 of course, but perhaps all traffic will be that?)

[edited by: claus at 2:09 am (utc) on April 17, 2005]

Merlin2000

2:04 am on Apr 17, 2005 (gmt 0)

10+ Year Member



Hmm.. The code you posted does nothing at all when I implement it into my .htaccess. The only thing I have in my .htaccess are a bunch of commented lines with #

Merlin2000

2:08 am on Apr 17, 2005 (gmt 0)

10+ Year Member



Just saw your edit... For some reason I cannot edit my last message.

I want all traffic [domain.com...] and [domain.com...] to be treated as [domain.com...]

Let me re-ask my question, and give this example of what I want done, I think this will be the easiest way to accomplish what I want.

When you access [domain.com...] , you should be directed to [domain.com...]

When you access [domain.com...]

You should be redirected to [domain.com...]

When you access [domain.com...] you should not be redirected to a secure connection.

Also, there is one other folder that needs to be secure. So when you access [domain.com...] it should redirect you to [domain.com...]

Hope this helps explain what I am looking for.

claus

2:17 am on Apr 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Okay, i'll try again:

1) In

www.example.com/.htaccess
:

---------------------------------------- 
RewriteEngine On

RewriteRule ^secure$ [domain.com...] [R=301,L]

RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301,L]
----------------------------------------

1) In

www.example.com/secure/.htaccess
:

---------------------------------------- 
RewriteCond %{REQUEST_URI} !^/secure/another-page-thats-not-secure.php
RewriteCond %{SERVER_PORT} !^443$ [OR]
RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301,L]
----------------------------------------

Remember that there should be a space before each "!" - this forum eats them sometimes. Hope this will work :)

Merlin2000

2:37 am on Apr 17, 2005 (gmt 0)

10+ Year Member



Not sure what is wrong with your code...

Here is what happens now.

[domain.com...] > [domain.com...]
- Meaning this works -

[domain.com...] > [domain.com...]
- Meaning this works -

[domain.com...] > [domain.com...]
- Meaning this does not work -

[domain.com...] > [domain.com...]
- Meaning this works -

So the only issue is, when you goto secure/ with a trailing slash, you are not re-directed to the secure URL.

jdMorgan

3:15 am on Apr 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You may need to add

RewriteOptions inherit

to your code in /secure/

Jim

Merlin2000

3:34 am on Apr 17, 2005 (gmt 0)

10+ Year Member



Apparently I did not implement the /secure code correctly.

Here is what I am using now:

------------------------------------
public_html/.htaccess
------------------------------------
RewriteEngine On

RewriteRule ^secure-folder1$ [domain.com...] [R=301,L]
RewriteRule ^secure-folder2$ [domain.com...] [R=301,L]

RewriteCond %{HTTP_HOST}!^www\.domain\.com [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301,L]

------------------------------------
public_html/secure-folder1/.htaccess
------------------------------------
RewriteEngine On
RewriteOptions inherit

RewriteCond %{REQUEST_URI}!^/secure-folder1/another-folder/non-secure-page.php
RewriteCond %{SERVER_PORT}!^443$ [OR]
RewriteCond %{HTTP_HOST}!^www\.domain\.com [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301,L]

------------------------------------
public_html/secure-folder2/.htaccess
------------------------------------
RewriteEngine On
RewriteOptions inherit

RewriteCond %{SERVER_PORT}!^443$ [OR]
RewriteCond %{HTTP_HOST}!^www\.domain\.com [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301,L]

<Files .htaccess>
order allow,deny
deny from all
</Files>

DirectoryIndex index.php
Options -Indexes

php_value "magic_quotes_gpc" "1"
php_value "register_globals" "1"
php_value "error_reporting" "2039"

-------------------------------------
-------------------------------------
Here are the tests:
[domain.com...] > [domain.com...]
[domain.com...] > [domain.com...]
-------------------------------------------
[domain.com...] > [domain.com...]

[domain.com...] > [domain.com...]

[domain.com...] > [domain.com...]
--------------------------------------------
[domain.com...] > [domain.com...]

[domain.com...] > [domain.com...]
--------------------------------------------

I just double checked everything.

--- Btw, there are spaces bwteeen the } and the!
--- If it makes things easier, I can send you the URL via PM/Email and you can take a look at what happens.

claus

2:17 pm on Apr 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Unfortunately i don't have a lot of time today, but i made a quick web search [google.com] and perhaps i found something helpful.

(1) Try this in

/.htaccess
(almost the same as now):

------------------------------------------ 
#turn on rewrite engine
RewriteEngine On

#if there's no trailing slash, rewrite it
RewriteRule ^secure-folder1$ [domain.com...] [R=301,L]
RewriteRule ^secure-folder2$ [domain.com...] [R=301,L]

#if there's a host field, AND
RewriteCond %{HTTP_HOST} .
#it does not have www prefix
RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
#rewrite it
RewriteRule ^(.*)$ [domain.com...] [R=301,L]
------------------------------------------

(2) And this in

/secure/.htaccess

------------------------------------------ 
#inherit rewrite options from folder above
RewriteOptions inherit

#put www prefix on non-secure url
RewriteCond %{REQUEST_URI} /secure-folder1/another-folder/non-secure-page.php [NC]
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301,L]

# if access is not SSL
<IfModule !mod_ssl.c>
# if it's not the non-secure url, AND
RewriteCond %{REQUEST_URI} !^/secure-folder1/another-folder/non-secure-page.php [NC]
#if there's a host field, AND
RewriteCond %{HTTP_HOST} .
#if it hasn't got www prefix
RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
#rewrite it
RewriteRule ^(.*)$ [domain.com...] [R=301,L]
</IfModule>
------------------------------------------

In (2) i stripped the port condition, i'm not sure it's required. If it is it can just be re-inserted. In (1) the dot in the host field is a tip i got from Jim, it makes the rule work only for user agents that do provide the host field so you don't get loops.

(NOTE: Rules have been edited since first post and once more since first edit)

Merlin2000

3:48 pm on Apr 17, 2005 (gmt 0)

10+ Year Member



Still doesn't work :/

Now the secure-folder1 doesn't rewrite to https no matter how you go their.

[domain.com...] > [domain.com...]

Everything else doesn't work.

Merlin2000

4:06 pm on Apr 17, 2005 (gmt 0)

10+ Year Member



Maybe we should just focus on making [domain.com...] to be secure when you goto [domain.com...] and [domain.com...]

Then take the next step in making it so that the one page that remains unsecure, stays unsecure.

claus

4:58 pm on Apr 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ain't that a b****

anyway, in msg #10 you had most of it set up right, it seems. What you need could be as easy as change these two in

/.htaccess
:

-----------------------------
RewriteRule ^secure-folder1$ [domain.com...] [R=301,L]
RewriteRule ^secure-folder2$ [domain.com...] [R=301,L]
-----------------------------

Here's a suggestion for the three

.htaccess
files:

----------------------------- 
www.example.com/.htaccess
-----------------------------
#turn on the engine
RewriteEngine On

#first, correct the www if necessary
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule ^(.*)$ [example.com...] [R=301]

#then, rewrite paths for secure folder 1
RewriteCond %{REQUEST_URI} !^/secure-folder1/another-folder/non-secure-page.php [NC]
RewriteCond %{REQUEST_URI} ^/secure-folder1 [NC]
RewriteCond %{REQUEST_URI} !^/secure-folder1/ [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301,L]

#then, rewrite paths for secure folder 2
RewriteCond %{REQUEST_URI} ^/secure-folder2 [NC]
RewriteCond %{REQUEST_URI} !^/secure-folder2/ [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301,L]
-----------------------------

-----------------------------
-----------------------------
www.example.com/secure-folder1/.htaccess
-----------------------------
(no content necessary - just delete it)
-----------------------------

-----------------------------
-----------------------------
www.example.com/secure-folder2/.htaccess
-----------------------------
RewriteOptions inherit

<Files .htaccess>
order allow,deny
deny from all
</Files>

DirectoryIndex index.php
Options -Indexes

php_value "magic_quotes_gpc" "1"
php_value "register_globals" "1"
php_value "error_reporting" "2039"
-----------------------------

- i sure would think this should do it all. Then again, i thought so above as well :)

Merlin2000

5:10 pm on Apr 17, 2005 (gmt 0)

10+ Year Member



Ok, this is weird..

[domain.com...] > [domain.com...]

[domain.com...] > [domain.com...]

[domain.com...] > [domain.com...]

[domain.com...] > [domain.com...]

I am going to go put this on another domain, and I will post the details for that domain, that way we can list actual domains -_-

claus

5:33 pm on Apr 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Great, we're almost there then :)

-----------------------------
www.example.com/.htaccess
-----------------------------
#turn on the engine
RewriteEngine On

#first, correct the www if necessary
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule ^(.*)$ [example.com...] [R=301]

#then, rewrite secure folder 1
RewriteCond %{REQUEST_URI} !^/secure-folder1/another-folder/non-secure-page.php [NC]
RewriteCond %{REQUEST_URI} ^/secure-folder1 [NC]
RewriteCond %{HTTPS} !on [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301,L]

#then, rewrite secure folder 2
RewriteCond %{REQUEST_URI} ^/secure-folder2 [NC]
RewriteCond %{HTTPS} !on [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301,L]

#then, rewrite slashes for secure folder 1
RewriteCond %{REQUEST_URI} ^/secure-folder1 [NC]
RewriteCond %{REQUEST_URI} !^/secure-folder1/ [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301,L]

#then, rewrite slashes for secure folder 2
RewriteCond %{REQUEST_URI} ^/secure-folder2 [NC]
RewriteCond %{REQUEST_URI} !^/secure-folder2/ [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301,L]
-----------------------------
[/pre]

I found RewriteCond %{HTTPS} [apache2docs.paradoxical.co.uk] - i think that should take care of the things taht were not missing.

claus

5:34 pm on Apr 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Great, we're almost there then :)

-----------------------------  
www.example.com/.htaccess
-----------------------------
#turn on the engine
RewriteEngine On

#first, correct the www if necessary
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule ^(.*)$ [example.com...] [R=301]

#then, rewrite secure folder 1
RewriteCond %{REQUEST_URI} !^/secure-folder1/another-folder/non-secure-page.php [NC]
RewriteCond %{REQUEST_URI} ^/secure-folder1 [NC]
RewriteCond %{HTTPS} !on [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301,L]

#then, rewrite secure folder 2
RewriteCond %{REQUEST_URI} ^/secure-folder2 [NC]
RewriteCond %{HTTPS} !on [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301,L]

#then, rewrite slashes for secure folder 1
RewriteCond %{REQUEST_URI} ^/secure-folder1 [NC]
RewriteCond %{REQUEST_URI} !^/secure-folder1/ [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301,L]

#then, rewrite slashes for secure folder 2
RewriteCond %{REQUEST_URI} ^/secure-folder2 [NC]
RewriteCond %{REQUEST_URI} !^/secure-folder2/ [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301,L]
-----------------------------

I found RewriteCond %{HTTPS} [apache2docs.paradoxical.co.uk] - i think that should take care of the things taht were not missing.

claus

5:35 pm on Apr 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Great, we're almost there then :)

-----------------------------  
www.example.com/.htaccess
-----------------------------
#turn on the engine
RewriteEngine On

#first, correct the www if necessary
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule ^(.*)$ [example.com...] [R=301]

#then, rewrite secure folder 1
RewriteCond %{REQUEST_URI} !^/secure-folder1/another-folder/non-secure-page.php [NC]
RewriteCond %{REQUEST_URI} ^/secure-folder1 [NC]
RewriteCond %{HTTPS} !on [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301,L]

#then, rewrite secure folder 2
RewriteCond %{REQUEST_URI} ^/secure-folder2 [NC]
RewriteCond %{HTTPS} !on [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301,L]

#then, rewrite slashes for secure folder 1
RewriteCond %{REQUEST_URI} ^/secure-folder1 [NC]
RewriteCond %{REQUEST_URI} !^/secure-folder1/ [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301,L]

#then, rewrite slashes for secure folder 2
RewriteCond %{REQUEST_URI} ^/secure-folder2 [NC]
RewriteCond %{REQUEST_URI} !^/secure-folder2/ [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301,L]
-----------------------------

I found RewriteCond %{HTTPS} [apache2docs.paradoxical.co.uk] - i think that one should take care of the things that were not working.

Merlin2000

5:39 pm on Apr 17, 2005 (gmt 0)

10+ Year Member



Here we go.

accounttest.info/cpanel
u/p [] accountt/password

These are what should be tested I believe:
[accounttest.info...] [should add ww before domain]
[accounttest.info...] [should stay http]
[accounttest.info...] [should goto https ]
[accounttest.info...] [should goto https ]
[accounttest.info...] [should stay http]
[accounttest.info...] [should goto https ]
[accounttest.info...] [should goto https ]

---------------------------
public html / .htaccess
---------------------------
#turn on the engine
RewriteEngine On

#first, correct the www if necessary
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST}!^www\.accounttest\.info [NC]
RewriteRule ^(.*)$ [accounttest.info...] [R=301]

#then, rewrite paths for helpdesk
RewriteCond %{REQUEST_URI}!^/helpdesk/admin/parser.php [NC]
RewriteCond %{REQUEST_URI} ^/helpdesk [NC]
RewriteCond %{REQUEST_URI}!^/helpdesk/ [NC]
RewriteRule ^(.*)$ [accounttest.info...] [R=301,L]

#then, rewrite paths for modernbill
RewriteCond %{REQUEST_URI} ^/modernbill [NC]
RewriteCond %{REQUEST_URI}!^/modernbill/ [NC]
RewriteRule ^(.*)$ [accounttest.info...] [R=301,L]

---------------------------
public_html / helpdesk / .htaccess
---------------------------
--nothing--
---------------------------
public html / modernbill/ .htaccess
---------------------------
RewriteOptions inherit

------------------------------------------------
Using the above code, here is the outcome for the tests:

[accounttest.info...] > [accounttest.info...]
[accounttest.info...] > [accounttest.info...]
[accounttest.info...] > [Error: connection refused]
[accounttest.info...] > [accounttest.info...]
[accounttest.info...] > [accounttest.info...]
[accounttest.info...] > [accounttest.info...]
[accounttest.info...] > [accounttest.info...]
------------------------------------------------

Merlin2000

5:45 pm on Apr 17, 2005 (gmt 0)

10+ Year Member



Here is the code I am using now, I will go test this:

#turn on the engine
RewriteEngine On

#first, correct the www if necessary
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST}!^www\.accounttest\.info [NC]
RewriteRule ^(.*)$ [accounttest.info...] [R=301]

#then, rewrite secure folder 1
RewriteCond %{REQUEST_URI}!^/helpdesk/admin/parser.php [NC]
RewriteCond %{REQUEST_URI} ^/helpdesk [NC]
RewriteCond %{HTTPS}!on [NC]
RewriteRule ^(.*)$ [accounttest.info...] [R=301,L]

#then, rewrite secure folder 2
RewriteCond %{REQUEST_URI} ^/modernbill [NC]
RewriteCond %{HTTPS}!on [NC]
RewriteRule ^(.*)$ [accounttest.info...] [R=301,L]

#then, rewrite slashes for secure folder 1
RewriteCond %{REQUEST_URI} ^/helpdesk [NC]
RewriteCond %{REQUEST_URI}!^/helpdesk/ [NC]
RewriteRule ^(.*)$ [accounttest.info...] [R=301,L]

#then, rewrite slashes for secure folder 2
RewriteCond %{REQUEST_URI} ^/modernbill [NC]
RewriteCond %{REQUEST_URI}!^/modernbill/ [NC]
RewriteRule ^(.*)$ [accounttest.info...] [R=301,L]

-----
Ok, I get a ton of connection refused.

Maybe I messed up on the spacing a bit?
[accounttest.info...]

claus

7:15 pm on Apr 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Okay, try replacing these lines:

RewriteCond %{HTTPS}!on [NC]

- with lines like this:

RewriteCond %{SERVER_PORT} !^443$

Merlin2000

7:30 pm on Apr 17, 2005 (gmt 0)

10+ Year Member



This is what happens now..

[domain.com...] > [domain.com...]

[domain.com...] > [domain.com...]

------------------------
#turn on the engine
RewriteEngine On

#first, correct the www if necessary
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST}!^www\.accounttest\.info [NC]
RewriteRule ^(.*)$ [accounttest.info...] [R=301]

#then, rewrite secure folder 1
RewriteCond %{REQUEST_URI}!^/helpdesk/admin/parser.php [NC]
RewriteCond %{REQUEST_URI} ^/helpdesk [NC]
RewriteCond %{SERVER_PORT}!^443$
RewriteRule ^(.*)$ [accounttest.info...] [R=301,L]

#then, rewrite secure folder 2
RewriteCond %{REQUEST_URI} ^/modernbill [NC]
RewriteCond %{SERVER_PORT}!^443$
RewriteRule ^(.*)$ [accounttest.info...] [R=301,L]

#then, rewrite slashes for secure folder 1
RewriteCond %{REQUEST_URI} ^/helpdesk [NC]
RewriteCond %{REQUEST_URI}!^/helpdesk/ [NC]
RewriteRule ^(.*)$ [accounttest.info...] [R=301,L]

#then, rewrite slashes for secure folder 2
RewriteCond %{REQUEST_URI} ^/modernbill [NC]
RewriteCond %{REQUEST_URI}!^/modernbill/ [NC]
RewriteRule ^(.*)$ [accounttest.info...] [R=301,L]

claus

7:45 pm on Apr 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Okay? Everything else working?

Then just remove the exact parts "

helpdesk/
" and "
modernbill/
" from the rewrite rules and you should be set :)

Merlin2000

7:50 pm on Apr 17, 2005 (gmt 0)

10+ Year Member



Which parts do I remove?

Like this?

#turn on the engine
RewriteEngine On

#first, correct the www if necessary
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST}!^www\.accounttest\.info [NC]
RewriteRule ^(.*)$ [accounttest.info...] [R=301]

#then, rewrite secure folder 1
RewriteCond %{REQUEST_URI}!^/helpdesk/admin/parser.php [NC]
RewriteCond %{REQUEST_URI} ^/helpdesk [NC]
RewriteCond %{SERVER_PORT}!^443$
RewriteRule ^(.*)$ [accounttest.info...] [R=301,L]

#then, rewrite secure folder 2
RewriteCond %{REQUEST_URI} ^/modernbill [NC]
RewriteCond %{SERVER_PORT}!^443$
RewriteRule ^(.*)$ [accounttest.info...] [R=301,L]

#then, rewrite slashes for secure folder 1
RewriteCond %{REQUEST_URI} ^/helpdesk [NC]
RewriteCond %{REQUEST_URI}!^/helpdesk/ [NC]
RewriteRule ^(.*)$ [accounttest.info...] [R=301,L]

#then, rewrite slashes for secure folder 2
RewriteCond %{REQUEST_URI} ^/modernbill [NC]
RewriteCond %{REQUEST_URI}!^/modernbill/ [NC]
RewriteRule ^(.*)$ [accounttest.info...] [R=301,L]

claus

8:42 pm on Apr 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That looks right to me, just remember those "!" - spaces :)

Btw. it seems i have posted the same message three times above, as i was trying to edit it - for future readers of this thread, it is the third one that is the right one (there are some minor differences, i think).

Merlin2000

8:49 pm on Apr 17, 2005 (gmt 0)

10+ Year Member



It loops when I goto [domain.com...]

but doesn't loop when I goto [domain.com...]

It also does not add the https..

claus

9:07 pm on Apr 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's simply incredible *lol*

Okay, i can see there might be a loop. Try adding a slash to the end of these two conditions, as shown below (i've included the comment so that you can see which ones). That way the URL without the slash will only get caught by the "slash" rules at the end:

--------------------------------------- 
#then, rewrite secure folder 1
RewriteCond %{REQUEST_URI} !^/helpdesk/admin/parser.php [NC]
RewriteCond %{REQUEST_URI} ^/helpdesk/ [NC]

(...)

#then, rewrite secure folder 2
RewriteCond %{REQUEST_URI} ^/modernbill/ [NC]
---------------------------------------

I really, really hope that this will do it...

Merlin2000

9:16 pm on Apr 17, 2005 (gmt 0)

10+ Year Member



--------------------------------------
#turn on the engine
RewriteEngine On

#first, correct the www if necessary
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST}!^www\.domain\.com [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301]

#then, rewrite paths for secure folder 1
RewriteCond %{REQUEST_URI}!^/helpdesk/admin/parser.php [NC]
RewriteCond %{REQUEST_URI} ^/helpdesk/ [NC]
RewriteCond %{REQUEST_URI}!^/helpdesk/ [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301,L]

#then, rewrite paths for secure folder 2
RewriteCond %{REQUEST_URI} ^/modernbill/ [NC]
RewriteCond %{REQUEST_URI}!^/modernbill/ [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301,L]
--------------------------------------

[domain.com...] > [domain.com...]

[domain.com...] > [domain.com...]

Same thing with the ModernBill directory.

I actually think that I can get around having to have the /helpdesk/admin/parser.php page unsecure. So if it makes things easier, we can remove that.

claus

9:30 pm on Apr 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't recognize the logic in the rules you just posted - i'll just post the whole thing with the changes i suggested last time:

---------------------------------------- 
#turn on the engine
RewriteEngine On

#first, correct the www if necessary
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.accounttest\.info [NC]
RewriteRule ^(.*)$ [accounttest.info...] [R=301]

#then, rewrite secure folder 1
RewriteCond %{REQUEST_URI} !^/helpdesk/admin/parser.php [NC]
RewriteCond %{REQUEST_URI} ^/helpdesk/ [NC]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ [accounttest.info...] [R=301,L]

#then, rewrite secure folder 2
RewriteCond %{REQUEST_URI} ^/modernbill/ [NC]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ [accounttest.info...] [R=301,L]

#then, rewrite slashes for secure folder 1
RewriteCond %{REQUEST_URI} ^/helpdesk [NC]
RewriteCond %{REQUEST_URI} !^/helpdesk/ [NC]
RewriteRule ^(.*)$ [accounttest.info...] [R=301,L]

#then, rewrite slashes for secure folder 2
RewriteCond %{REQUEST_URI} ^/modernbill [NC]
RewriteCond %{REQUEST_URI} !^/modernbill/ [NC]
RewriteRule ^(.*)$ [accounttest.info...] [R=301,L]
----------------------------------------

Merlin2000

9:42 pm on Apr 17, 2005 (gmt 0)

10+ Year Member



Just to make sure everything I have is correct (spaces an all) I updated accounttest.info/htaccess.txt to reflect all changes.

Now when I goto [domain.com...] it takes me to [domain.com...]

But when I goto [domain.com...] it loops (and gives redirection error).

This 37 message thread spans 2 pages: 37