Forum

Need help with rewrite rule

Marcus Vieß
4 January 2016, 16:50
Hello,

can somebody help my with this rewrite rule ?
RewriteEngine on
RewriteBase /x3/check
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !image/
RewriteRule ^(.+)$ image/$1 [L]

Thank you,

Marcus
Marcus
4 January 2016, 21:14
Forget what i wrote above.
I am trying to install imagevue x3.
Above was a test file from imagevue.

This are the real imagevue x3 rules :
# Prevent access to various folders with exceptions
RewriteCond %{REQUEST_FILENAME} !app/parsers/slir [NC]
#RewriteRule ^(app|templates|extensions)/ - [NC,F]

# RewriteBase
# Some hosts require a RewriteBase rule to allow the rewriteEngine to function relative to your domain path. You can normally see if this is the case by going to your /check/ page. If RewriteBase is required, uncomment the line below.
# EXAMPLE 1: if running x3 in domain root, RewriteBase /
# EXAMPLE 2: if running from a root folder named 'x3', RewriteBase /x3
# RewriteBase /

# Customize what Apache returns to the client in case of an error.
ErrorDocument 404 /404.html

# Rewrite any calls to *.html, *.json, *.xml, *.atom, *.rss, *.rdf or *.txt if a folder matching * exists
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !public/
RewriteCond %{DOCUMENT_ROOT}/public/$1.$2 !-f
RewriteRule (.+)\.(html|json|xml|atom|rss|rdf|txt)$ $1/ [L]

# Add a trailing slash to directories
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.|\?)
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ([^/]+)$ $1/ [L]

# Rewrite any calls to /render to the image parser
RewriteCond %{REQUEST_URI} render/
RewriteRule ^render/. app/parsers/slir/ [L]

# Redirect to main domain if using a subdomain- or separate domain to server static assets.
# RewriteCond %{HTTP_HOST} !^domain.com$ [NC]
# RewriteCond %{REQUEST_FILENAME} !\.(js|css|png|jpg|jpeg|gif|woff|ttf|eot|svg)$ [NC]
# RewriteCond %{REQUEST_URI} !app/parsers/slir/
# RewriteRule (.*) http://domain.com/$1 [R=301,L]

# Rewrite any calls to /* or /app to the index.php file
RewriteCond %{REQUEST_URI} /app/$
RewriteRule ^app/ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ index.php?/$1/ [L,QSA]

# Rewrite any file calls to the public directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !public/
RewriteRule ^(.+)$ public/$1 [L]

# Allow basic authentication
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

Thanks in advance ...

Marcus
Hugo Leisink
4 January 2016, 22:56
This rewrite rule looks like a compete mess, so no guarantees this will work. The imagevue x3 developers are not really good developers if you ask me.

ErrorDocument 404 /404.html

Use the ErrorHandler option for this.

# Rewrite any calls to *.html, *.json, *.xml, *.atom, *.rss, *.rdf or *.txt if a folder matching * exists
RequestURI isfile Return
Match ^/public/ Return
Match ^/(.+)\.(html|json|xml|atom|rss|rdf|txt)$ Rewrite /$1/

# Add a trailing slash to directories
RequestURI exists Return
Match (\.|\?) Return
Match (.*)/$ Return
Match ^/([^/]+)$ Rewrite /$1/

# Rewrite any calls to /render to the image parser
Match ^/render/. Rewrite /app/parsers/slir/

# Rewrite any calls to /* or /app to the index.php file
Match ^/app/ Rewrite /index.php
RequestURI exists Return
Match ^/(.*)/$ /index.php?/$1/ [QSA]

# Rewrite any file calls to the public directory
Match ^/public/ Return
Match ^/(.+)$ Rewrite /public/$1


RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

Use the HTTPAuthToCGI option for this.
Marcus Vieß
5 January 2016, 16:27
Thanks for yor help.

Still don't work. But i cannot test it complete because i got a syntax error in this Section :

# Rewrite any calls to /* or /app to the index.php file
Match ^/app/ Rewrite /index.php
RequestURI exists Return
Match ^/(.*)/$ /index.php?/$1/ [QSA]

PS: I am using Hiawatha 10
Hugo Leisink
6 January 2016, 08:52
Oh, forgot to fix "Match ^/(.*)/$ /index.php?/$1/ [QSA]". This one should be
Match ^/(.*)/\?(.*)$ /index.php?/$1/&$2
Match ^/(.*)/$ Rewrite /index.php?/$1/
Marcus Vieß
6 January 2016, 19:23
Hello,

sorry, but i still got the Syntax Error.

Thats what i have now :
UrlToolkit {
ToolkitID = imagevue

# Rewrite any calls to *.html, *.json, *.xml, *.atom, *.rss, *.rdf or *.txt if a folder matching * exists
RequestURI isfile Return
Match ^/public/ Return
Match ^/(.+)\.(html|json|xml|atom|rss|rdf|txt)$ Rewrite /$1/

# Add a trailing slash to directories
RequestURI exists Return
Match (\.|\?) Return
Match (.*)/$ Return
Match ^/([^/]+)$ Rewrite /$1/

# Rewrite any calls to /render to the image parser
Match ^/render/. Rewrite /app/parsers/slir/

# Rewrite any calls to /* or /app to the index.php file
RequestURI exists Return
Match ^/app/ Rewrite /index.php
# Match ^/(.*)/\?(.*)$ /index.php?/$1/&$2
Match ^/(.*)/$ Rewrite /index.php?/$1/

# Rewrite any file calls to the public directory
Match ^/public/ Return
Match ^/(.+)$ Rewrite /public/$1
}

Syntax Error is on the # line.

can i do something to help ?

The Website with the gallery is here : http://mviess.de/x3

Nginx Rewrite rules are here : http://imagevuex.com/forum/viewtopic.php?f=54&t=8617&p=37453&hilit=nginx#p37453

Maybe it helps a little ?

Thank you, Marcus ...
Hugo Leisink
7 January 2016, 13:40
I forgot the Rewrite statement.
Match ^/(.*)/\?(.*)$ Rewrite /index.php?/$1/&$2

No offense, but with a little manpage reading and looking at the issue, you could have solved it yourself.
Marcus Vieß
7 January 2016, 21:08
Facepalm. Yes ... right.

Sorry and tank you !

This topic has been closed.