How to create a htaccess file in WordPress? - php

I went to my WordPress root folder to search for a .htaccess file but it was not there. Can I create one of my own .htaccess file and put it there so I can do the modifications in it?
Please guide me.
Thank you.

Create a new text file on your computer and name it .htaccess
Save it, it will be named ".htaccess.txt"
Remove the .txt, making it simply ".htaccess", and add anything you want to it.
Upload the file into your root folder.
Profit

Related

change wordpress image upload to another directory in public_html

I want to set my wordpress files to upload to /home/public_html/images instead of /wp_content/uploads, I have gotten to the point that it gives me the correct url for /home/public_html/images but I have to move the new files from /wp_content/uploads to /home/public_html/images for it to work
I have tried changing the upload path in wp-options.php but that just makes a subdirectory in my sites folder called public_html and puts the image there instead of actually putting it in /home/public_html/images
Try going to the wp_config.php file and adding this line of code:
define('UPLOADS', 'images');
This should put the images in a folder under /public_html instead of the typical /wp_content folder.
https://developer.wordpress.org/apis/wp-config-php/#moving-uploads-folder

Laravel 8 UniSharp File Manager 3 change base directory from app/storage to app/public

I am struggling to change the base directory to upload images to be in app/public instead of the default app/storage.
There is no base_directory in the config/lfm.php file.
I also see that the lfm.php file is in the unisharp/laravel-filemanager/src/config folder. Why is this config file in 2 places?
The reason I need to change to have this structure is that I already have hundreds of images in public/images and files in public/files and I want to keep these links in the existing pages working.
So what do I have to do to change that?
Maybe if you change in config/lfm.php, line with 'disk' => 'lfm_local', resolve your problem.
lfm_local is localized in the file config/filesystems.php, there you see some options of disks, to use at lfm.php.

Uploading a file with PHP and moving it

I have a form where users can upload images. I know how to do it with HTML/PHP and I know that I have to move the temp file to the permanent directory. Well this all works well when my file that processes the form, is in the root directory. But, I would like to have it work within another directory, on the same server.
The Structure is this:
ROOT
>images
>mobile
>upload.php
I would like to have the file put inside images, which is outside of the "mobile" directory.
My current upload path that does not work is:
define('UPLOADPATH', 'images/');
So essentially I need to go back one directory and then into images. How can I do this?
You need to add a .. To move to the parent directory. See this resource for more information

upload file outside of root folder

public_html/(root)index.php
/image/123.jpg
/subdomain(root)/upload.php
I have file upload.php can upload image, this file is locate in sub-domain folder (I have set sub-domain folder as another root)
I need to upload image to main domain, /image/ (image's folder)
however I could not find the right path. I have try ../ but it wont work above the root
anyone know how to solve this problem?
Use path like /home/content/html/images

Is my temp folder discoverable after image upload form?

I have a simple php image upload form that saves the images in a temporary folder, lets call it temp, and when the image is approved by me I manually copy it to the album folder.
My question is, if there is a way for someone or I don't know, a search engine maybe to find "guess" my temp folder and what images are inside ( before approve ).
You wrote it yourself:
The temp is inside public_html
Doesn't that answer your question?
If this is not desirable, create a .htaccess file inside the temp folder, with this content:
Deny from all
It depends on the location of the temp folder. If the folder lies outside the root directory of your server its not discoverable but if it lies inside the root directory it is discoverable. However you can limit the access to your temp folder if its inside the root of the server through htaccess. Or you can place a index.php file inside the folder with a header redirect so that no one can see the file(image) list.

Categories