How to reset htaccess redirects? - php

I was attempting to make the root of a directory redirect to a folder within it. (Eg. http://host.com/folderA/ redirect to http://host.com/folderA/folderB/
After various attempts of doing this, I kind of broke it..
The folder now redirects to the web root (http://host.com/)
And now I can't get the folder back to normal, no matter what I try.. it just keeps redirecting back to the web root. I tried adding a blank htaccess file and tried redirecting it to other folders but it remains redirecting to the root.
I no longer want it to redirect at all because I now just want to link to the folder from an index page. Is there any method of resetting redirects for this folder?

Related

Site redirects to index.php without www

I am trying to verify my SSL certificate for my website.
So I did upload a file to my server but when I try to access the file it is only working when i enter the url with www when I do it without www it redirects me to the index of my wordpress page.
Here is the url which redirects to index.php without the www
http://vanloonautobedrijf.nl/.well-known/pki-validation/3619BF0D6B387464A49478D183780BF0.txt
I did empty my htaccess file and still cant reach it without www
You have a redirection (301) configured somewhere which redirects all non-www requests to the same URL (see attached screenshot). In your case, it's not what you need, because the path info + query string is lost during that redirection.
When you find where is your redirection defined, try fixing it by setting the option to keep the path/query from the original URLs. The exact method to achieve this is specific to the way the redirection was implemented.
If you find where your redirection was configured, update your question and we might be able to help you fix it.

Rewrite URL only wothout redirecting the page

I have a wordpress site installed on a domain, inside a subfolder. Now my client wants to show it as the default page, but I don't know how to do it without reinstalling WP to the root directory of the server.
I simply want to rewrite to URL of mysite.com/wp to mysite.com, and other subfolderls like mysite.com/wp/a-wordpress-page to mysite.com/a-wordpress-page
What I've tried so far:
Placed an index.php to the root with header redirect, but it will rewrite the URL to /wp
Including the /wp/index.php to the main index.php. It works when you open the page, but after following any link on the site, the /wp/ part will show up again.
Tried some RewriteRules in .htaccess but can't figure out how to do it correctly.
So what is the easiest solution to do it with .htaccess or PHP?

Ignore index.php in subfolder

I have an app where every request gets sent through the index.php front controller. Pretty standard.
The admin interface will be loaded through domain.com/admin.
We want to put public assets for the admin area in a folder named admin.
The problem is when I add the folder, accessing the /admin URL results in it trying to load domain.com/admin/index.php
Is it possible to ignore the subfolder's index.php, or only allow js/css/image files to be served through the subfolder?
Or we could even put an index.php in there which somehow redirects to the root URL? I tried this but it resulted in an infinite redirect loop.
Yes, you may redefine DirectoryIndex to "forget" about index.php:
DirectoryIndex index.html
So now only index.html will be served if found, otherwise it will be HTTP 404
We ended up just using a different folder name to serve assets.

Folder structure website php

Lets say I have the website url www.example.com. My index.php page is in the root directory. I then want to have a page at www.example.com/someDir as well as a page at www.example.com/someDir/anotherDir. I thought that I would make the directory someDir in the root directory and make the directory anotherDir within the directory someDir, then place an index.php page in both those new directories which would be the visible page at those URLs.
Is this the proper way?
Yes.
Note that your web server (apache or whatever) should redirect www.example.com/someDir to www.example.com/someDir/ (with a trailing slash) which will make the relative links work correctly with respect to the index.php files.

how to use htacces to restrict access to all files in a folder and it's subfolders and redirect to main?

So I'm on a 15-day trial of my (already paid) webhosting and they seem very good, at least they did until I got my FTP.
I have a php script that needs a folder outside of the root directory
Example:
website root:
/users/websites/public_html/ <- folder which users / browsers have access to
The script needs a folder here:
/users/websites/ <- above the root
for example /users/websites/sensetive_data/ <- browsers cannot acces this
but that's impossible on my web-host "because it's a shared hosting" <- their answer. And they can't change the root path.
So I cannot create any directories or files above /users/websites/public_html/
So, well, to no cancel my trial immediately, maybe I will try to do it in another way, I want to use htacces to restrict acces to a directory, and all the files in it and it's subdirectories,
So I can move the 'sensetive_data' folder to /users/websites/public_html/sensetive_data
I want it to redirect to the main page (so when accessing /users/websites/public_html/sensetive_data/* [http://example.com/sensetive_data/*] it will go to /users/websites/public_html/ [http://example.com/],
so even if the user knows the exact url, he/she will be redirected. How can I accomplish that?
If you want to do a redirect for a folder, say /users/websites/sensitive_data/
create a file in that folder called .htaccess and add the following (and specify the url to redirect to)
Options -Indexes
ErrorDocument 403 http://mysite.net/
In /users/websites/sensetive_data/.htaccess write:
Deny From All
For your whatever PHP script you need to change it yourself.

Categories