Welcome Guest, Not a member yet? Register   Sign In
Rewrite + Authentication
#11

[eluser]bretticus[/eluser]
[quote author="JanDoToDo" date="1274132365"]Is the main one, and the same auth lines in the payment directory
The script is in /payment/payment_result.php

Code:
RewriteEngine on

RewriteBase /

RewriteRule ^payment - [L]

RewriteCond $1 !^(index\.php|index\.html|assets|payment|robots\.txt)

RewriteRule ^(.*)$ /index.php/$1 [L]
[/quote]

Your condition goes with the last rule. It should go before your condition for the last rule. Try my change.
#12

[eluser]JanDoToDo[/eluser]
Ok, with that change, the page no longer gives a 500 ISE but the payment page is now again "page cannot be found".

It must be trying to rewrite the url, but the payment folder is in the excluded list??

Is it the rewrite rule
RewriteRule ^(.*)$ /index.php/$1 [L]

Doesnt the " ^(.*)$ " bit tell it to rewrite anything, even regardless of whether it was in the previous condition? Or if it doesnt meet the previous condition does the rewrite just cease completely? shall I try adding it to the final rule?
#13

[eluser]JanDoToDo[/eluser]
Also, what is $1? What does that evaluate to? How can I find out?
#14

[eluser]bretticus[/eluser]
[quote author="JanDoToDo" date="1274132707"]Ok, with that change, the page no longer gives a 500 ISE but the payment page is now again "page cannot be found".

It must be trying to rewrite the url, but the payment folder is in the excluded list??

Is it the rewrite rule
RewriteRule ^(.*)$ /index.php/$1 [L]

Doesnt the " ^(.*)$ " bit tell it to rewrite anything, even regardless of whether it was in the previous condition? Or if it doesnt meet the previous condition does the rewrite just cease completely? shall I try adding it to the final rule?[/quote]

Yes, RewriteRule ^(.*)$ /index.php/$1 [L] says take any URI and rewrite it to /index.php/[whatever uri got matched]

The $1 is a regular expression substitution for what got matched in the subpattern (.*) which means 0 or more of anything.

However, this is not the problem. It's doing its job.

You did throw me off when you excluded a URL that apparently CI needs to process.


Code:
RewriteRule ^payment - [L]

Should be:

Code:
RewriteRule ^assets - [L]

Right? Since you DO NOT WANT any rewriting being performed specifically for the /assets/scripts/payment/ folder according to your original post. Am I missing something here?
#15

[eluser]bretticus[/eluser]
[quote author="JanDoToDo" date="1274132365"]Is the main one, and the same auth lines in the payment directory
The script is in /payment/payment_result.php
[/quote]

So you need to reach scripts in the payment folder that are not process via CI? I'm a bit confused now.
#16

[eluser]JanDoToDo[/eluser]
Sorry - the payments folder is outside the assets folder, in fact alongside it> Directory structure:

--Doc Root---
+application
+system
+assets
+payment
index.php
#17

[eluser]JanDoToDo[/eluser]
Yes - The payment script inside the payment folder cannot be processed by CI, well actually I guess as long as there is Basic Authentication enabled on the folder then it would be ok but that is proving more difficult than it sounds!
#18

[eluser]bretticus[/eluser]
Okay,

So putting this:

Code:
RewriteRule ^(payment|assets) - [L]

before the index.php rewrite *should* tell apache to not mess with the current URI if assets or payments is matched and skip any further rules. Again, this *should* work.

Curious. Have you tried turning off mod_rewrite in the protected folder .htaccess files?

Code:
RewriteEngine off
#19

[eluser]JanDoToDo[/eluser]
Ok, so these are my htaccess files:

Main .htaccess
Code:
Options +FollowSymLinks
RewriteEngine on

RewriteBase /

#RewriteCond %{REQUEST_URI} !^/(index\.php|index\.html|assets|payment|robots\.txt) [NC]
#RewriteRule ^(.*)$ index.php/%1 [L]

#RewriteCond %{REQUEST_URI} !^/payment
#RewriteRule ^(.*)$ index.php?%1 [L]

#RewriteCond %{REQUEST_URI} !^/payment
#RewriteRule ^/payment [L]

RewriteRule ^(payment|assets) - [L]

RewriteCond $1 !^(index\.php|index\.html|assets|payment|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

#RewriteCond $1 !^(index\.php|index\.html|assets|payment|robots\.txt)
#RewriteRule ^(.*)$ /index.php/$1 [L]

(Notice all the options I've tried!!!!!)

The change you just mentioned still doesnt work! Sad

.htaccess in subdirectory :
Code:
RewriteEngine off

AuthName "Admin section"
AuthUserFile "/home/studentc/.htpasswds/public_html/assets/scripts/payment/passwd"
AuthType Basic
require valid-user
#20

[eluser]bretticus[/eluser]
This may be that apache can't find the error document and the 404 is coming from apache (not CI) which I should have asked in the beginning. You can tell it to ignore the error document with the following addition:


Code:
ErrorDocument 401 "Unauthorized Access"

RewriteEngine off

AuthName "Admin section"
AuthUserFile "/home/studentc/.htpasswds/public_html/assets/scripts/payment/passwd"
AuthType Basic
require valid-user

If this doesn't work. I am plain stumped. Good luck!




Theme © iAndrew 2016 - Forum software by © MyBB