Pathing from ../ in subdomain - apache

Lets say I create a subdomain : http://subdomain.mydomain.com/
That was originally at this url : http://mydomain.com/subfolder/folder/
How would I fix pathing issues for
../ on http://subdomain.mydomain.com/
without a replacing code in .htaccess? is it possible?

let say I have some masive structure like this.
Now in this case I want to do is in the css -> style -> loginCSS I have a css file named as login and I want to take that
ca_grain_texture.jpg and set it as a background of my login.html file so we see that our html files are in the main directory
and also our css folder is in main directory
so if i want to grab the grain jpg file from my login.css file. I have to do somthing like this.
e.g
body{
background-image: url(../../../images/cs_grain_texture.jpg);
}
on writing ../ everytime it will jump one folder back similar to cd/ in command shell.
../ means it will go to loginCSS folder.
../../ means style folder.
../../../ means css which is the main directory.
I hope it helps understanding I understood this way and hope it clears your view.

Related

How to Serving static files with express if it is inside a subdirectory

I am having trouble with serving a html file which is inside a subdirectory inside public folder.
My directory structure looks like:
public/
HTML/
index.html
index.js
I want to serve the index.html for the root route.
This doesn't work:
app.use('/',express.static(path.join(__dirname,'public')));
According to the docs, this should be enough:
app.use(express.static('public'))
It also gives you such example
http://localhost:3000/images/kitten.jpg
http://localhost:3000/css/style.css
http://localhost:3000/js/app.js
http://localhost:3000/images/bg.png
http://localhost:3000/hello.html
It doesn't go much further other than explaining how you can set up multiple public directories. Anyway, it has worked for me in my projects.
Perhaps you need to state directly app.use(express.static('html')) or app.use(express.static('public/html')). Let me know what works for you.

Reference HTML file in iframe with Quasar framework

I need to open an static HTML file inside an iframe because I need it to be printed silently, I’m trying setting the iframe src with absolete and relative paths but none of them work, I’ve tried moving my files inside public, static and assets folders with no success, I’ve seen that some people uses process.env.BASE_URL to access absole path of environment but it doesn’t work in Quasar.
Currently I have my files in a folder called ticketTemplates inside public folder placed at root, and it has two files: first.html and first.css, I’m doing the following:
<iframe src="ticketTemplates/first.html" frameborder="1"></iframe>
But as I said before it does not with relative or absolute paths. I've tried with http://localhost:8080/ticketTemplates/first.html too and it does not work.
Could you tell me how to achieve it?
I opened this tread in Quasar Forum and I found I was using an outdated version of #quasar/app, I updated my project and the content worked inside my iframe.
I moved my ticketTemplates folder inside public folder located in root directory, next to quasar.conf.js file and the resulting code was:
<iframe src="http://localhost:8080/ticketTemplates/first.html" frameborder="1"></iframe>
All the credit goes to the user who helped me.

How to generate txt & xml files in nuxt SSR?

Is there any way of generating a Google : ads.txt file every time i build my SSR project?
There is a module called: sitemap-module from nuxt-community, it is used to generate a sitemap xml file, and that file can be accessed by http://domain.tls/sitemap.xml. and i want something like that.
So currently i'am achieving this by building the project, then manually put ads.txt it in : /var/www/site/.nuxt/dist/client/,
The problem with this is that everytime i rebuild the project i loose /var/www/site/.nuxt/dist/client/ folder then i have to add ads.txt file again.
I would like to know how i can hook up my code to tell nuxt to generate ads.txt file and put it in /var/www/site/.nuxt/dist/client/
Not sure if it makes sense, but i hope someone will understand.
Place your ads.txt file in a directory named static as mentioned here. All the contents of the static directory can be accessed via example.com/{filename.extension}
If you are not using nuxt.js and just using vue js, place it in a public directory right next to src directory.
Haven't found any way of solving this in nuxt, so i decided to redirect all https://domain.tld/ads.txt in Nginx configuration.
/etc/nginx/sites-available/default.conf
#redirect all txt request
location ~* ^.+.(txt)$ {
root /var/www/other.files/;
}
So i think i'll stick to it.

How to create new folders on my domain name

As you can tell from the title, I don't know what words that I should use to describe what I want to do.
I just want to be able to change my website's files from:
www.example.com/bark.php
and www.example.com/leaves.php
to
www.example.com/tree/bark.php
www.example.com/tree/leaves.php
While having a www.example/tree.php page as well.
So, I'm working with PHP and am building this with Sublime text editor. Is this an .htaccess job?
Thanks in advance :)
You don't need .htaccess or any programming language.
Simply create the folder, put your files in it, and upload them back to the server. You'll also want to delete the old files on the server as well.
Alternatively, you can rename the files on the server itself. You can either right-click on the target file, and click 'Move'.
You can also drag the files directly by clicking-and-dragging:
The file www.example.com/tree.php is just another file, stored in the ROOT folder. You are allowed to have a folder and a file with the same name.
www.example.com/tree will point to the tree folder, and attempt to access the index at www.example.com/tree/index.html or www.example.com/tree/index.php.
The file www.example.com/tree.php will not be loaded when viewing www.example.com/tree without .htaccess configuration.
Hope this helps! :)

Laravel wrong public path file upload

I've deployed laravel with this guide.
http://juniorgrossi.com/deploying-laravel-applications-on-a-shared-host/
On my webserver I have a public_html file now containing all my publicly accesable files and a laravel folder containing the rest, so I've split up the default laravel structure for deployment.
On my development server by default the public folder is resting inside the laravel folder instead of being on the same directory level.
The problem I'm getting though is when I use something like this:
// Upload the file
Input::upload('image', 'public/uploads', $filename);
Same with this.
// Upload the file
Input::upload('image', path('public') . 'uploads', $filename);
Instead of trying to use the uploads folder that is inside my public_html folder it tries looking for a public file inside my laravel folder now.
And I get a
Unable to create the "/uploads" directory
Ofcourse on my development server the public folder is still inside the folder so it's logical.
How do I fix this?
You may try this (add a slash after the folder name)
Input::upload('image', path('public') . 'uploads/', $filename);
Maybe try this....just as a test
Input::upload('image', URL::to_asset('uploads/'), $filename);
You can also try
Intervention/image package.
I'm using this and I find it very easy to use. It also has a resize and crop feature.
It's easy as:
Image::make(Input::file('file')->getRealPath())->save('uploads/' . $filename);
Fixed the paths.php to ../public_html
I've done this before but it failed since I accidentaly uploaded a png and my jcrop function wich crops and saves images failed because it currently onlt takes jpg. So that left me thinking my paths.php settings were no good while they actually were.
Thanks for helping out though everybody!
(I feel like a fool.)
In my case, I got the same problem. Then I created it manually, CHMODed the lil' bastard and it worked fine!
Making a long history short (not so long...): just permission!
If you have the permission to Write/Read to the folder, you'll be cool! If you don't, you change the permissions! If you are unable to change it, put the uploaded files where the permissions allows you to access the file.