Apache requests to subdirectory does not return index












0















I have an apache2 server on ubuntu. I use the apache configuration file to achieve multiple things like hiding file extensions, forwarding http to https, etc. My configuration file has the side effect that requests to domain.net/api (or any other subdirectory) returns a 404, and not the index file of that directory.



I have the following configuration file for my apache virtual host (where @ are used for anonymity). There is no htaccess file in use.



<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin @@@@
ServerName @@@@@@.net
ServerAlias www.@@@@@@.net
DirectoryIndex index.php
DocumentRoot /var/www/@@@@@@.net/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

<Directory "/var/www/@@@@@@.net/html">
AllowOverride All
</Directory>

<Directory "var/www/@@@@@@.net/html/api">
DirectoryIndex index.php
</Directory>

# Custom error pages
ErrorDocument 400 /error
ErrorDocument 401 /error
ErrorDocument 403 /error
ErrorDocument 404 /error
ErrorDocument 500 /error

RewriteEngine on

# Remove www
RewriteCond %{HTTP_HOST} ^www.@@@@@@.net$
RewriteRule ^(.*)$ https://@@@@@.net$1 [R=301,L]

# Remove trailing slash
RewriteCond %{THE_REQUEST} ^(?!GET./.H.*$)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ $1 [L,R=301]

# Rewrite /foo/bar to /foo/bar.php
RewriteCond %{REQUEST_FILENAME} !^/$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+)$ $1.php [NC,L]

# Return 404 if the original request is /foo/bar.php
RewriteCond %{THE_REQUEST} "^[^ ]* .*?.php[? ].*$"
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* - [L,R=404]

# SSL stuff
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/@@@@@.net/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/@@@@@.net/privkey.pem
</VirtualHost>
</IfModule>









share|improve this question



























    0















    I have an apache2 server on ubuntu. I use the apache configuration file to achieve multiple things like hiding file extensions, forwarding http to https, etc. My configuration file has the side effect that requests to domain.net/api (or any other subdirectory) returns a 404, and not the index file of that directory.



    I have the following configuration file for my apache virtual host (where @ are used for anonymity). There is no htaccess file in use.



    <IfModule mod_ssl.c>
    <VirtualHost *:443>
    ServerAdmin @@@@
    ServerName @@@@@@.net
    ServerAlias www.@@@@@@.net
    DirectoryIndex index.php
    DocumentRoot /var/www/@@@@@@.net/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory "/var/www/@@@@@@.net/html">
    AllowOverride All
    </Directory>

    <Directory "var/www/@@@@@@.net/html/api">
    DirectoryIndex index.php
    </Directory>

    # Custom error pages
    ErrorDocument 400 /error
    ErrorDocument 401 /error
    ErrorDocument 403 /error
    ErrorDocument 404 /error
    ErrorDocument 500 /error

    RewriteEngine on

    # Remove www
    RewriteCond %{HTTP_HOST} ^www.@@@@@@.net$
    RewriteRule ^(.*)$ https://@@@@@.net$1 [R=301,L]

    # Remove trailing slash
    RewriteCond %{THE_REQUEST} ^(?!GET./.H.*$)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ $1 [L,R=301]

    # Rewrite /foo/bar to /foo/bar.php
    RewriteCond %{REQUEST_FILENAME} !^/$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^.]+)$ $1.php [NC,L]

    # Return 404 if the original request is /foo/bar.php
    RewriteCond %{THE_REQUEST} "^[^ ]* .*?.php[? ].*$"
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* - [L,R=404]

    # SSL stuff
    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateFile /etc/letsencrypt/live/@@@@@.net/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/@@@@@.net/privkey.pem
    </VirtualHost>
    </IfModule>









    share|improve this question

























      0












      0








      0








      I have an apache2 server on ubuntu. I use the apache configuration file to achieve multiple things like hiding file extensions, forwarding http to https, etc. My configuration file has the side effect that requests to domain.net/api (or any other subdirectory) returns a 404, and not the index file of that directory.



      I have the following configuration file for my apache virtual host (where @ are used for anonymity). There is no htaccess file in use.



      <IfModule mod_ssl.c>
      <VirtualHost *:443>
      ServerAdmin @@@@
      ServerName @@@@@@.net
      ServerAlias www.@@@@@@.net
      DirectoryIndex index.php
      DocumentRoot /var/www/@@@@@@.net/html
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined

      <Directory "/var/www/@@@@@@.net/html">
      AllowOverride All
      </Directory>

      <Directory "var/www/@@@@@@.net/html/api">
      DirectoryIndex index.php
      </Directory>

      # Custom error pages
      ErrorDocument 400 /error
      ErrorDocument 401 /error
      ErrorDocument 403 /error
      ErrorDocument 404 /error
      ErrorDocument 500 /error

      RewriteEngine on

      # Remove www
      RewriteCond %{HTTP_HOST} ^www.@@@@@@.net$
      RewriteRule ^(.*)$ https://@@@@@.net$1 [R=301,L]

      # Remove trailing slash
      RewriteCond %{THE_REQUEST} ^(?!GET./.H.*$)
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)/$ $1 [L,R=301]

      # Rewrite /foo/bar to /foo/bar.php
      RewriteCond %{REQUEST_FILENAME} !^/$
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^([^.]+)$ $1.php [NC,L]

      # Return 404 if the original request is /foo/bar.php
      RewriteCond %{THE_REQUEST} "^[^ ]* .*?.php[? ].*$"
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule .* - [L,R=404]

      # SSL stuff
      Include /etc/letsencrypt/options-ssl-apache.conf
      SSLCertificateFile /etc/letsencrypt/live/@@@@@.net/fullchain.pem
      SSLCertificateKeyFile /etc/letsencrypt/live/@@@@@.net/privkey.pem
      </VirtualHost>
      </IfModule>









      share|improve this question














      I have an apache2 server on ubuntu. I use the apache configuration file to achieve multiple things like hiding file extensions, forwarding http to https, etc. My configuration file has the side effect that requests to domain.net/api (or any other subdirectory) returns a 404, and not the index file of that directory.



      I have the following configuration file for my apache virtual host (where @ are used for anonymity). There is no htaccess file in use.



      <IfModule mod_ssl.c>
      <VirtualHost *:443>
      ServerAdmin @@@@
      ServerName @@@@@@.net
      ServerAlias www.@@@@@@.net
      DirectoryIndex index.php
      DocumentRoot /var/www/@@@@@@.net/html
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined

      <Directory "/var/www/@@@@@@.net/html">
      AllowOverride All
      </Directory>

      <Directory "var/www/@@@@@@.net/html/api">
      DirectoryIndex index.php
      </Directory>

      # Custom error pages
      ErrorDocument 400 /error
      ErrorDocument 401 /error
      ErrorDocument 403 /error
      ErrorDocument 404 /error
      ErrorDocument 500 /error

      RewriteEngine on

      # Remove www
      RewriteCond %{HTTP_HOST} ^www.@@@@@@.net$
      RewriteRule ^(.*)$ https://@@@@@.net$1 [R=301,L]

      # Remove trailing slash
      RewriteCond %{THE_REQUEST} ^(?!GET./.H.*$)
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)/$ $1 [L,R=301]

      # Rewrite /foo/bar to /foo/bar.php
      RewriteCond %{REQUEST_FILENAME} !^/$
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^([^.]+)$ $1.php [NC,L]

      # Return 404 if the original request is /foo/bar.php
      RewriteCond %{THE_REQUEST} "^[^ ]* .*?.php[? ].*$"
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule .* - [L,R=404]

      # SSL stuff
      Include /etc/letsencrypt/options-ssl-apache.conf
      SSLCertificateFile /etc/letsencrypt/live/@@@@@.net/fullchain.pem
      SSLCertificateKeyFile /etc/letsencrypt/live/@@@@@.net/privkey.pem
      </VirtualHost>
      </IfModule>






      apache apache2






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 25 '18 at 1:16









      sgtbpsgtbp

      556




      556
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53463873%2fapache-requests-to-subdirectory-does-not-return-index%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53463873%2fapache-requests-to-subdirectory-does-not-return-index%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Tonle Sap (See)

          I get strange results when I access the Sqlitedatabase with Unity C# via XAMPP

          Guatemaltekische Davis-Cup-Mannschaft