Thursday, February 17, 2022

[FIXED] CakePhp3 Htaccess

Issue

I want to access image file in this folder by local.myproject/assets/logo.jpg Note that /img/ folder is not in the URL

|-webroot
    |-js
    |-img
       |-assets
           |-logo.jpg

How can i configure this on my htaccess currently my .httacess under webroot is like

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
    RewriteRule ^assets/(.*)$ img/assets/$1 [R=301,L]
</IfModule>

And this is not working.


Solution

Try the following rule :

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^assets(.*)$ /img/assets$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>


Answered By - Hasta Dhana

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.