help with rewrite

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)

hope someone can help! thanks


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!
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


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.
Thanks for your help Kevin;

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

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


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/
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

The .htaccess file then use's a redirect (per the above post) to send back to:

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.


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.