stargateatlantis
asked on
.htaccess directory issue
Struggling with this in a .htaccess file
the root folder has the following folders
/myweb
/api
/spa
in the spa folder there is a folder called /dist
and in the api folder there is a folder called /api/public/
when somebody types mydomain.com/ it will access the /spa/dist folder and access all the assets under so the page displays
when somebody access the /api folder it will access the /api/public folder
but no redirects it will be rewrites.
the root folder has the following folders
/myweb
/api
/spa
in the spa folder there is a folder called /dist
and in the api folder there is a folder called /api/public/
when somebody types mydomain.com/ it will access the /spa/dist folder and access all the assets under so the page displays
when somebody access the /api folder it will access the /api/public folder
but no redirects it will be rewrites.
ASKER
That worked but here is a issue.
the source code points to the following css path /css/styles.css but the file doesn't exist another rewrite needs to be done so that anything with the following will be pointing to the dist folder
images | css | js
so so everything works now just we need the images css and js folder to be rewritten in apache
the source code points to the following css path /css/styles.css but the file doesn't exist another rewrite needs to be done so that anything with the following will be pointing to the dist folder
images | css | js
so so everything works now just we need the images css and js folder to be rewritten in apache
Try
If they are linked as in a folder you could try:
If not if the website is internet facing if you could give me a link to see how it is displaying or paste the source code.
RewriteRule ^(.*\.(gif|jpg|png))$ /spa/dist/$1 [QSA,L]
RewriteRule ^(.*\.(js))$ /spa/dist/$1 [QSA,L]
RewriteRule ^(.*\.(css))$ /spa/dist/$1 [QSA,L]
If they are linked as in a folder you could try:
RewriteRule ^images/(.*)$ /spa/dist/$1 [R=301,NC,L]
RewriteRule ^css/(.*)$ /spa/dist/$1 [R=301,NC,L]
RewriteRule ^js/(.*)$ /spa/dist/$1 [R=301,NC,L]
If not if the website is internet facing if you could give me a link to see how it is displaying or paste the source code.
1) Tip: Only use 302s. If you use 301s, then you'll end up with links cached in your browser forever. This means no changes you make will register in your browser, till you clear your cache.
2) For mydomain.com to reach /myweb/spa/dist the simple solution is to make the the document root, so no .htaccess entry.
3) Place files in /api/public/* folder into /myweb/spa/dist/api to serve those files.
Seems like you're making this overly complex.
If I understand your question correctly, there's no requirement for any .htaccess rules, just a simple directory hierarchy.
4) Mentioning styles.css suggests you may be working with a WordPress site, so best describe the code you're working with.
For example, custom code or some CMS code like WordPress, as this will limit or change any type of .htaccess contents you use.
2) For mydomain.com to reach /myweb/spa/dist the simple solution is to make the the document root, so no .htaccess entry.
3) Place files in /api/public/* folder into /myweb/spa/dist/api to serve those files.
Seems like you're making this overly complex.
If I understand your question correctly, there's no requirement for any .htaccess rules, just a simple directory hierarchy.
4) Mentioning styles.css suggests you may be working with a WordPress site, so best describe the code you're working with.
For example, custom code or some CMS code like WordPress, as this will limit or change any type of .htaccess contents you use.
ASKER
So what would be best so that nothing gets cached. You can include that in the .htaccess as well
ASKER
Here is the issue
this code here
Its linked like this in code.
the file doesn't exist but it exists in spa/dist/js/app.d44788ce.j s
this code doesn't work
Or this
this code here
Its linked like this in code.
<link href=/js/app.d44788ce.js rel=preload as=script>
the file doesn't exist but it exists in spa/dist/js/app.d44788ce.j
this code doesn't work
RewriteRule ^images/(.*)$ /spa/dist/$1 [R=301,NC,L]
RewriteRule ^css/(.*)$ /spa/dist/$1 [R=301,NC,L]
RewriteRule ^js/(.*)$ /spa/dist/$1 [R=301,NC,L]
Or this
RewriteRule ^(.*\.(gif|jpg|png))$ /spa/dist/$1 [QSA,L]
RewriteRule ^(.*\.(js))$ /spa/dist/$1 [QSA,L]
RewriteRule ^(.*\.(css))$ /spa/dist/$1 [QSA,L]
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That sorta of worked but if you go here
/spa/dist/img/logo.82b9c7a 5.png
The image will show up but what I need is
/spa/img/logo.82b9c7a5.png
should be able to do that without the redirect
/spa/dist/img/logo.82b9c7a
The image will show up but what I need is
/spa/img/logo.82b9c7a5.png
should be able to do that without the redirect
RewriteRule ^spa/img/(.*)$ /spa/dist/img/$1 [R=302,NC,L]
ASKER
I tried that doesn't work here is the code
I get 404 errors
RewriteEngine on
RewriteCond %{HTTP_HOST} lamc\.com [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ /spa/dist/$1 [L]
RewriteRule ^api/(.*)$ /api/public/$1 [R=302,NC,L]
RewriteRule ^spa/img/(.*)$ /spa/dist/img/$1 [R=302,NC,L]
RewriteRule ^spa/js/(.*)$ /spa/dist/js/$1 [R=302,NC,L]
RewriteRule ^spa/css/(.*)$ /spa/dist/css/$1 [R=302,NC,L]
I get 404 errors
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If I understand, you're trying to...
1) Arrange your assets (files) across some directories.
2) Then reference these assets by a different path.
3) With no redirects.
Likely answer will be to just use symlinks on the disk.
This means your .htaccess file will be empty.
1) Arrange your assets (files) across some directories.
2) Then reference these assets by a different path.
3) With no redirects.
Likely answer will be to just use symlinks on the disk.
This means your .htaccess file will be empty.
No Problem,
Please select the solutions that helped so that the question can be closed.
Kenza
Please select the solutions that helped so that the question can be closed.
Kenza
Open in new window
You may have a problem with the API folder though