How to redirect folder paths for Apache, e.g. for all images

Practice




How do I redirect folder paths for Apache, for example for all images

in .htaccess

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/folderonsite/(.*?)$ /backup/folderwithfiles/$1 [L]
or
RewriteRule ^folderonsite/(.*?) /home/folderwithfiles/$1 [L]



it doesn't work, it says url not found — I don't need the redirect on the hosting, I need it done on the server in a different folder not from the hosting account

then check whether the alias module is enabled
and try adding this to the apache config

Alias /pathonsite/ /home/realpathtofile/

or

AliasMatch ^/pathonsite/(.*)$ /home/realpathtofile/$1

apache gives an error: Apache error "AliasMatch not allowed here"

AliasMatch and Alias are not available in .htaccess

you must place them only in the Apache config.

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Running server side scripts using PHP as an example (LAMP)"

Terms: Running server side scripts using PHP as an example (LAMP)