I would like to display a certain path in the URL but actually server content from another path using htaccess

Neil Thompson
Neil Thompson used Ask the Experts™
on
Hi all

I would like to display a certain path in the URL but actually server content from another path. How can I achieve the following using my .htaccess Apache file please?

I want to have a URL with the word attachments
http://192.168.0.19:8282/attachments/0d00286c16186148b1c30949aec269d1/3.jpg

but actually serve the content located at /images/plots/
http://192.168.0.19:8282/images/plots/0d00286c16186148b1c30949aec269d1/3.jpg

Thanks in advance, Neil
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Consultant & Challenge Subduer
Top Expert 2009
Commented:
You're looking for "mod rewrite". Here's a tutorial that seems to answer your question: https://www.elated.com/mod-rewrite-tutorial-for-absolute-beginners/ Example 2 may be particularly helpful.

Here's another article on it: https://www.smashingmagazine.com/2011/11/introduction-to-url-rewriting/

Here's the official documentation: http://httpd.apache.org/docs/current/mod/mod_rewrite.html
Neil ThompsonSenior Systems Developer

Author

Commented:
superb, many thanks :)
Neil ThompsonSenior Systems Developer

Author

Commented:
Just in case anyone is after the outcome it was:


RewriteRule ^attachments/([^~]+)/?$ /images/plots/$1

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial