help with rewrite

#1
Hi All,
Hoping you can help me;

In an apache environment:
in a subdirectory /CDN/
there is a .htaccess file with this:

RewriteEngine on
RewriteRule ^[0-9]{1,6}/(.*)$ ../$1 [PT]

In openlitespeed i tried the following:

in rewrite tab i tried the following

RewriteRule ^/cdn/[0-9]{1,6}/(.*)$ ../$1 [PT]

That didnt work;

So tried setting up a context (static) will little luck !

(see screenshot) https://www.dropbox.com/s/m85y5td64d8jlay/screenshot.jpg?dl=0

hope someone can help! thanks
 

lsfoo

Administrator
#2
Hi Rudi,

Give this rewrite rule a try:

RewriteRule ^/cdn/([0-9]{1,6})/(.*)$ /$1/$2 [PT]

You can also turn on rewrite logging wherever you enabled rewrite to check out what happened with the rewrite rule.

Let me know if it works!
Kevin
 
#3
Thanks Kevin
Is tried and it didnt work, but i wasnt able to see anything in the logs, assume its in the $VHOST\logs areas? i had Log Level set at 9
Rudi
 

lsfoo

Administrator
#4
Hi Rudi,

I apologize for not being clear. Please check the server log $SERVER_ROOT/logs/error.log

In the main server config, the log level should be set to INFO or DEBUG as well.

Please let us know if you are able to view the log messages.
Kevin
 
#5
Thanks for your help Kevin;

The only thing i can see relevant in the log was:

2015-05-13 06:15:45.819 [INFO] [216.158.88.67:50910] [REWRITE] Rule: Match '/' with pattern '/cdn/([0-9]{1,6})/(.*)$', result: -1
 

lsfoo

Administrator
#6
Hi Rudi,

Based on the log, you tried to access a page that matched '/' only. Are you attempting to access a link with the /CDN/ subdirectory? It may be because the rewrite rule is lower case, /cdn/
 
#7
Im not sure if i am doing the right thing; some background:

I am using an extension in magento for amazon cloudfront (content delivery network)
The extension change's the image url
from: http://www.domain.com.au/media/cata...42ffe127f42dca9de82fb58b1/d/-/d-5_custom_.jpg
to: http://www.domain.com.au/cdn/68890/...42ffe127f42dca9de82fb58b1/d/-/d-5_custom_.jpg

The .htaccess file then use's a redirect (per the above post) to send back to: http://www.domain.com.au/media/cata...42ffe127f42dca9de82fb58b1/d/-/d-5_custom_.jpg

I don't know why the extension does this or is setup this way, but this is required to use the "invalidation" function

So under an apache environment that seems to work.
 

lsfoo

Administrator
#8
Hi Rudi,

The cdn should be sending a request to OLS with the url including '/cdn/68890/...', but OLS only sees the '/', so it won't match with the rewrite rule.

We'll need to see what the error log is showing. There should be a line that includes something like:
New request: ..Method=[GET], URI=[/index.html],..QueryString=[(null)]..Content Length=0

When you access the image, do you see the image or an error page?

Or perhaps the request isn't handled by the cdn first, so it isn't sending a request with the extra added.

Kevin
 
Top