Reputation: 155
Is there a way you can change the absolute path for a subfolder via .htaccess?
My dillema:
Site URL is http://localhost/build
But When I use an absolute path like:
<script src="/assets/script.js"></script>
OR
<a href="/projects/">Projects</a>
The URL changes to http://localhost/assets/script.js
and http://localhost/projects
I need it them to be
http://localhost/build/assets/script.js
and http://localhost/build/projects
Absolute paths need to be used for this project.
Upvotes: 1
Views: 1268
Reputation: 155
I placed the following in the .htaccess in the root directory i.e. http://localhost
. Works for both href
and src
tags.
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/build
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^.*$ /build/$0 [L]
Hope this helps someone else.
Upvotes: 2