• Welcome to the Chevereto user community!

    Here users from all over the world gather around to learn the latest about Chevereto and contribute with ideas to improve the software.

    Please keep in mind:

    • 😌 This community is user driven. Be polite with other users.
    • 👉 Is required to purchase a Chevereto license to participate in this community (doesn't apply to Pre-sales).
    • 💸 Purchase a Pro Subscription to get access to active software support and faster ticket response times.

Problem with rewriterule

Shadow777

Chevereto Member
Hello guys

I use chevereto2 for an site with a couple of tools.

I want to short the link to the sites with a rewrite rule in .htaccess

for example:
RewriteRule ^tool/(.*)$ /tools/sometool/$1 [L]
RewriteRule ^img/(.*)$ /tools/chevereto/$1 [L]

If I go now to "domain.tld/tool" I see the site in "domain.tld/tools/sometool/"
But if I go to "domain.tld/img" I see only a 404 error.

So I think the problem is connected to chevereto...

Can anybody help me to find a solution for this problem?


Sorry for bad english, I'am not a native english speaker :/
 
Those rules should be placed before the main Chevereto rewrite rule, otherwise Chevereto rule will be used (The [L] flag means last rule)
 
:confused: Sorry, I have not so many experiences with rewrite rules...

You have said that I should place my rewrite rule before the chevereto rules, but how I can do this without remove the L(ast) Flag ? I'am a little bit confused :/
 
Your .htaccess should look like this:

Code:
# Disable server signature
ServerSignature Off

# Disable directory listing (-indexes), Multiviews (-MultiViews) and enable Follow system links (+FollowSymLinks)
Options -Indexes
Options -MultiViews
Options +FollowSymLinks

# Turn on mod_rewrite
RewriteEngine On

#HERE
RewriteRule ^tool/(.*)$ /tools/sometool/$1 [L]
RewriteRule ^img/(.*)$ /tools/chevereto/$1 [L]

# If you have problems with the rewrite rules remove the "#" from the following RewriteBase line
# You will also have to change the path to reflect the path to your Chevereto installation
#RewriteBase /chevereto

# The /api rewrite
RewriteRule ^api$ api.php [L]

# If you want to have your own fancy "image not found" image remove the "#" from RewriteCond and RewriteRule lines
# Make sure to apply the correct paths to reflect your current installation
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule images/.+\.(gif|jpe?g|png|bmp) content/system/img/404.gif [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.([a-z]{1,4})$ [NC]
RewriteRule . index.php [L]
 
Thanks, but this doesn't work :/

I think the problem is in the index.php or in one of the other included php files.
I get also an 404 error, if I remove all the content from the chevereto .htaccess.
But it works, if I try it with an empty index.php.

Do you have any idea, where exactly in the php files the problem is?
Of course I try to find it self, but maybe you have an spontaneous idea.
 
Is not in the index, is all in the .htaccess rules. Since this is a custom thing you need to try changing rules and stuff like that.
 
But its illogical... It also doesn't work, if I remove the whole .htaccess from chevereto. In other way; It works, if I use an alternative index.php. So for my understanding, the problem can only be the index.php or rather the chevereto.php.
 
Yeah well, is not like that. Just review your rules.

When you use .htaccess rules properly those actions happens before Apache calling the index.php file (that means the [L] flag, last rule to be applied if matches). If the index php file is called then your rules are wrong or they are being ignored by the Apache server, not by Chevereto.

So again, review your rules or refer to your hosting company. More info on .htaccess can be found here: http://httpd.apache.org/docs/2.2/howto/htaccess.html

Maybe your custom rules should be placed before the rewrite base line. Anyway, is not a Chevereto thing is how your configure your server.
 
Last edited:
Back
Top