Htaccess defaults to 404

Hi
I have a site that works as it should, made by a developer using YII with some directories at root level with symlinks with subdomains like
domain.tld
sub1.domain.tld
sub2.domain.tld
when going to the subs they display as subx.domain.tld and when going to domain.tld it will display as domain.tld/it/site

Like said it works fine, but if I add a new directory to domain.tld i.e. domain.tld/my-new-dir it displays the directory content (sub-directories, and files list), if I add and htaccess file to it and type domain.tld/my-new-dir in the address bar it returns a 404 and the address is domain.tld/it/my-new-dir,

I also tried to create a folder and named it “it” in which put my-new-dir, but it again returns 404 when adding htaccess to it.

Now I’d guess it has to do with the YII and symlinks plus htaccess setup, but unfortunatelly the developer is no longer available, and I would need to add new directory to the site.

Thank you

I think we would need to see your .htaccess file.

Here is the htaccess in the public_html
the htaccess of the new directory is the simple one to password protect it, I also tried one with only oprions -indexes

Options +FollowSymlinks

RewriteEngine on
RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule . index.php
# use index.php as index file
DirectoryIndex index.php

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php73” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php73 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

What do you expect to see in your new directory? My guess is the new directory does not have an index.php but index.html or index.htm which you expect to see, by Apache was configured to use index.php as index file (DirectoryIndex index.php).

You could try an .htacccess file in the new directory with DirectoryIndex index.html index.htm.

Thank you.

A php script, which has an index.php in it.

The problem occurs when I add the following htaccess to the directory.
Problem being it defaults to
domain.tld/it/php-script
instead of
domain.tld/php-script

AuthType Basic
AuthName "Area Protetta"
AuthUserFile /home/my-user/.htpasswd
require valid-user

To be sure I used the correct path I got the directory path by this php string
<?php echo getcwd(); ?>

I also tried (for the sake of testing) the .htpasswd in the same directory and using the following path
/home/my-user/public_html/php-script/.htpasswd

Note:
Last tests described in the current post were made without the script package, but with only an index.php

I solved it by creating a subdomain, and using that to install the script, and the htaccess protection.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.