K
K
Kirill Krasin2019-12-10 14:29:40
Apache HTTP Server
Kirill Krasin, 2019-12-10 14:29:40

How to find out why RewriteRule is not working?

Hello.
Faced apparently with a banal situation, however itself I can not solve it. You need to rewrite from this URL:

http://domain.tld/index.php?w=650&h=content&i=madam/rdo_map_nazar_1_sm.jpg

On that:
http://domain.tld/650/content/madam/rdo_map_nazar_1_sm.jpg

For implementation in htaccess I wrote the following:
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /index.php?w=$1&h=$2&i=$3 [L]

In apache2.conf:
<Directory /home/mo45/www>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

In vhost it is:
<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName domain.tld
    DocumentRoot /home/mo45/www/rockstar/weazel
        <Directory "/home/mo45/www/rockstar/weazel/">
                Options +FollowSymLinks -MultiViews
                RewriteEngine On
                AllowOverride ALL
                Allow from all
        </Directory>
    LogLevel alert rewrite:trace3
    ErrorLog /home/mo45/www/rockstar/log/error.log
    CustomLog /home/mo45/www/rockstar/log/access.log combined
</VirtualHost>

The following is in the logs:
[Tue Dec 10 14:20:08.457690 2019] [rewrite:trace3] [pid 3897] mod_rewrite.c(482): [client 141.101.104.182:60012] 141.101.104.182 - - [domain.tld/sid#7f3bd4704a30][rid#7f3bcb27f0a0/initial] [perdir /home/mo45/www/rockstar/weazel/] add path info postfix: /home/mo45/www/rockstar/weazel/650 -> /home/mo45/www/rockstar/weazel/650/content/madam/rdo_map_nazar_1_sm.jpg
[Tue Dec 10 14:20:08.457929 2019] [rewrite:trace3] [pid 3897] mod_rewrite.c(482): [client 141.101.104.182:60012] 141.101.104.182 - - [domain.tld/sid#7f3bd4704a30][rid#7f3bcb27f0a0/initial] [perdir /home/mo45/www/rockstar/weazel/] strip per-dir prefix: /home/mo45/www/rockstar/weazel/650/content/madam/rdo_map_nazar_1_sm.jpg -> 650/content/madam/rdo_map_nazar_1_sm.jpg
[Tue Dec 10 14:20:08.458039 2019] [rewrite:trace3] [pid 3897] mod_rewrite.c(482): [client 141.101.104.182:60012] 141.101.104.182 - - [domain.tld/sid#7f3bd4704a30][rid#7f3bcb27f0a0/initial] [perdir /home/mo45/www/rockstar/weazel/] applying pattern '^([^/]*)/([^/]*)/([^/]*)$' to uri '650/content/madam/rdo_map_nazar_1_sm.jpg'

mod_rewrite enabled , works on other vhosts. The index.php itself works without the rewrite as intended.
I can't figure out what the problem is.
Thanks in advance for your help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-12-10
@dodo512

^([^/]*)/([^/]*)/([^/]*)$
The string "650/content/file.jpg" fits this template, but "650/content/dir/file.jpg" does not.
^(\d+)/(content)/(.+)$

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question