#RewriteEngine On
#RewriteBase /csnew/

I commented out those two lines in my HTACCESS file, whenever I type in my domain address with a directory and/or file added on that doesn't exist, it keeps loading my web site because it's constantly searching within the directory /CSNEW/ but commenting it out, isn't preventing this ?

Changing Permissions and delete directories.

<Files .htaccess>
order allow,deny
deny from all
</Files>

From my understanding the above code, is preventing me from changing the permissions or deleting any directories. I commented it out, but I can't delete or change the permissions of any directory or file ?

Dani AI

Generated

Common reason non-existent URLs show your normal site instead of a 404 is that something on the server (not the browser) is catching the request and serving content. Based on the posts: disabled some local rewrite directives, and suggested redirects (which won't fix this). The likely causes are a global or parent-directory rewrite/front-controller, an ErrorDocument configured to an external URL (which ends up serving the homepage), mod_negotiation MultiViews, or your application routing returning a 200 while displaying a “not found” page.

Quick, conclusive checks you can run (from a shell or with browser dev tools):

curl -I http://yourdomain.tld/some/nonexistent/path

Expect either HTTP/1.1 404 Not Found or 200 OK. In the browser use the Network tab and inspect the response code and request path. Also check the webserver logs for the request—look in access and error logs for messages like “File does not exist” or for the request being forwarded to index.php.

Why you can’t delete directories: the <Files .htaccess> web rule only blocks HTTP access to that filename — it does not change filesystem ownership or block filesystem operations. Inability to delete is almost always a permissions/ownership issue. Inspect with:

ls -la /path/to/public_html
stat /path/to/public_html/suspectdir

If files are owned by another user (or marked immutable with lsattr), you’ll need correct user privileges, chown/chmod as root, or assistance from the host.

Practical fixes: add or correct an ErrorDocument so a true 404 is returned, and disable MultiViews if it’s matching requests:

ErrorDocument 404 /404.html
Options -MultiViews

If your site uses a front controller, update the application router to send an actual 404 status for missing resources. Back up .htaccess before edits and, on shared hosting without shell access, capture the curl output and logs and open a support ticket with your host quoting those results.

Recommended Answers

All 4 Replies

Member Avatar for Member #949455

whenever I type in my domain address with a directory and/or file added on that doesn't exist, it keeps loading my web site because it's constantly searching within the directory /CSNEW/ but commenting it out, isn't preventing this ?

You need to redirect the pages to the new pages:

//This will redirected the whole website from old to new.
Redirect /home/path/public_html/ 

//This will redirected certain pages
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^oldpage\.html$ "http\:\/\/www\.demo.domain\.com\/newpage\.php" [R=301,L]

I don't want to redirect pages to new pages. I want to know why, if I go to a page or a page within a directory on the server that doesn't exist, it continues to load up my web page instead of firing a 404 message ?

Member Avatar for Member #949455

I don't want to redirect pages to new pages. I want to know why, if I go to a page or a page within a directory on the server that doesn't exist, it continues to load up my web page instead of firing a 404 message ?

It shouldn't at all. 404 pages means no pages exist on that server.

Another words remove the link that is link to that page that you do not want the page to go to then the 404 page will appear.

I assume you change the nav menu bar to the new pages if you didn't change it then that page will come up instead of the 404 pages.

Sorry, I didn't understand :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.