URL is not showing 404 page - html

I have a domain domain.com
And when I type domain.com/something.html/new/one/square/new.html I am not getting a 404 error.
Where something.html is present in the account correctly.
Directory new is present in my document root.
Square is not present in my account.

By default, if part of the url points to a file, the rest of the url is treated as so-called "path info". In php you should be able to get this path info by checking $_SERVER['PATH_INFO']. If you don't want Apache to work like this, turn path info off in your main config file (httpd.conf) or in .htaccess in your root directory with the following directive.
AcceptPathInfo Off
For more information, please check the documentation for AcceptPathInfo.

Related

How do you use redirects (either a _redirects or toml file) in Netlify to redirect from a custom domain alias URL to a primary domain file path?

In my directory I have a _redirect file that contains the following:
https://revivifygame.com /revivify
According to the netlify docs, this should redirect revivifygame.com ---> itsmo.co.uk/revivify.
I own both domains mentioned above.
However, after deployment, the redirect is not working. Any help on what could be going wrong?

How can I serve static files with 404 redirection by PM2?

I already know that there is a simple command to serve static folder by PM2:
pm2 serve <path> <port>
But how can I add 404 redirection to it? e.g. redirect to 404.html while that happends. Can't find that on Google & PM2 doc.
By default, pm2 displays 404.html from the serving directory if it can't map a request to any static file of that directory. For example, assume that your static file directory name is foo, which contains three images - 1.jpg, 2.jpg, 3.jpg. You are serving those files using:
pm2 serve <path_of_foo> 8080
Now, if the server receives any request like http://localhost:8080/bar.jpg, pm2 will look for a file named 404.html on foo directory and display its contents, as bar.jpg does not exist. If it doesn't find any, it show a simple text message 404 Not Found. There is no options to make it configurable (CLI or JSON), as per my knowledge.
However, if you make this file path configurable, you can take a look at here and customize the source according to your need.

Have index.html file but still getting a directory listing

I have an index.html file in my Apache DocumentRoot directory but when I go to my URL, I am still getting a directory listing of my DocumentRoot directory instead of the index.html file being displayed. The apache access_log shows 200's when I reload the page. Any suggestions?
Use
DirectoryIndex index.html
It tells apache what document to show for a directory request.
update
You should specify just the filename that apache will look for in the folder requested.
Not saying this will fix it for you, but for me when first getting started with Apache2 it was file permissions that would get forgotten when moving or writing new file under the web root directory
ls -hal /var/www/host_one/index.html
If above doesn't have read (r) permissions for the same user:group or if the ownership doesn't include the user/group of the web server, then try the following for allowing group reads
# Modify ownership, change 'www_host' to Apache2 group
chown ${USER}:www_host /var/www/host_one/index.html
# give read+write (6) to user and read (4) to group owners
chmod 640 /var/www/host_one/index.html
Try refreshing the website and see if permissions where the issue. Note most web documents only require read permissions and ownership to be correct for browsers to be allowed to pick them up for rendering, on rare occasions you may need executable (1 or x) permissions for server scripts (be cautious of ownership in such cases) and last write permissions (2 or w) should likely never be seen without good reasons on files within your web root.
Second thing to try, use the index.html within your browsers URL bar
# by IP
http://192.168.0.100/index.html
# by domain
http://site-name.local/index.html
If the above loaded your document then, like #Pekka 웃 stated already, you've likely got a server option that's missing or enabling directory listings instead of looking for a index page within that directory. If this is the problem then there's two ways of fixing it that I've tried in the past. One, htaccess configuration to disable directory listing within that sub-directory, two, server vhost configuration to prevent whole site from directory listings. Personally I prefer to use option two and then on directories that should be allowed to be listed place an htaccess config for permissions instead of denials.

Plesk - Error adding subdomain "The specified directory contains a service directory"

I'm trying to create a subdomain and point it to etc/subdomains/home
Folder home only contains an index file.`
When I click ok I get this message: "The specified directory contains a service directory"
I tried with`etc/subdomains/home and etc/subdomains/home/index.php but I still get the error message.
What am I doing wrong?
I think etc folder is reserved for configs and other staff, not sure what the one would want web scripts in there. Try choosing any other folder like subdomain/home, htdocs/subdomain/home, subdomains/mysubdomain/home, etc.

Cannot find URL error while it is definitely there

I have small CGI script running on a server[Linux OS]. following is a part of script output..
<tr><td valign="center">Lol</td><td valign="center">10112</td><td>abc.pdf</td></tr>
But when I click on this abc.pdf hyperlink, browser displays error message:URL /home/pathtopdf/abc.pdf was not found on the server. while the pdf and path is definitely there and all files and folders in the path[including pdf] has full permission.
My server location is # /srv/www and script in /srv/www/cgi-bin, but when I put the link to pdf as follows
<tr><td valign="center">Lol</td><td valign="center">10112</td><td>abc.pdf</td></tr>
The error message was The requested URL '/srv/www/for_html/abc.pdf' resolves to a file which is marked executable but is not a CGI file; retrieving it is forbidden. Again permission is there for files.
What could be the problemo?
Your problem is that you try to request a file outside of the webroot. So by clicking that, the browser is really requesting
http://example.com/home/pathtopdf/abc.pdf
not
/home/pathtopdf/abc.pdf
You can edit your apache config file and add a virtual host to that directory under a subdomain (say downloads)
After your edit, I am assuming you are using the file:// protocol, directly on the server. I would say just to remove the executable bit from your .pdf's file permissions. Run from a shell:
chmod -x /srv/www/for_html/abc.pdf