1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

.htaccess doesn't work even after setting the allowOverride parameter in the vhost.

Discussion in 'Apache' started by thetechguy1970, Jun 4, 2020.

  1. #1
    Hi all.
    As the title says, .htaccess doesn't work even after I set the allowOverride All option in the vhost. Here is the exact section of the vhost.
    <Directory "/var/www/mydomain.tld/public-html">
    AllowOverride All
    </Directory>
    What am I doing wrong?
     
    thetechguy1970, Jun 4, 2020 IP
  2. SpacePhoenix

    SpacePhoenix Well-Known Member

    Messages:
    196
    Likes Received:
    28
    Best Answers:
    2
    Trophy Points:
    155
    #2
    What are you attempting to do?
     
    SpacePhoenix, Jun 4, 2020 IP
  3. thetechguy1970

    thetechguy1970 Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #3
    Trying to make .htaccess work for my wordpress site.
     
    thetechguy1970, Jun 4, 2020 IP
  4. RHS-Chris

    RHS-Chris Well-Known Member

    Messages:
    1,007
    Likes Received:
    35
    Best Answers:
    10
    Trophy Points:
    150
    #4
    Which web server are you running, on which platform?
     
    RHS-Chris, Jun 5, 2020 IP
  5. thetechguy1970

    thetechguy1970 Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #5
    I'm running apache on ubuntu 20.04 VPS.
     
    thetechguy1970, Jun 5, 2020 IP
  6. thetechguy1970

    thetechguy1970 Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #6
    Hi guys.
    Do you guys have any ideas on how to fix this?
     
    thetechguy1970, Jun 8, 2020 IP
  7. RHS-Chris

    RHS-Chris Well-Known Member

    Messages:
    1,007
    Likes Received:
    35
    Best Answers:
    10
    Trophy Points:
    150
    #7
    • What are the contents of the .htaccess file?
    • Does your Apache error log give any clues?
    • What happens if you put incorrect syntax in the .htaccess file, does it throw an error when loading your site?
     
    RHS-Chris, Jun 8, 2020 IP
  8. thetechguy1970

    thetechguy1970 Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #8
    1. The contents of the .htaccess file are the following.
    ErrorDocument 404 /var/www/my_website.com/public-html/404.php.
    2. The apache error log gives no clues. Plus, when I type in, apache2ctl configtest, it says syntax ok.
    3. Nothing happens. No errors when loading my site.
     
    thetechguy1970, Jun 8, 2020 IP
  9. RoseHosting

    RoseHosting Well-Known Member

    Messages:
    230
    Likes Received:
    11
    Best Answers:
    11
    Trophy Points:
    138
    #9
    So, you want to have a custom 404 page. You can change your current .htaccess content with this one, make sure the .htaccess and 404.php file are in the same directory, if not you can modify the 404.php file path:

    ErrorDocument 404 /404.php

    To test it, you need to go to a non-existent page, for example: yourdomain.com/a3813413dahbsdkasjd

    You should be able to see the custom 404 page.
     
    RoseHosting, Jun 8, 2020 IP
  10. thetechguy1970

    thetechguy1970 Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #10
    That doesn't work. It brings up the default error page in apache.
     
    thetechguy1970, Jun 8, 2020 IP
  11. RoseHosting

    RoseHosting Well-Known Member

    Messages:
    230
    Likes Received:
    11
    Best Answers:
    11
    Trophy Points:
    138
    #11
    Well, it means you need to modify the 404.php path in your .htaccess file, the /404.php means it's in the webroot.
     
    RoseHosting, Jun 8, 2020 IP
  12. thetechguy1970

    thetechguy1970 Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #12
    I did that. I set it as the absolute path of the file. /var/www/my_website.com/public-html/404.php.
     
    thetechguy1970, Jun 8, 2020 IP
  13. SpacePhoenix

    SpacePhoenix Well-Known Member

    Messages:
    196
    Likes Received:
    28
    Best Answers:
    2
    Trophy Points:
    155
    #13
    SpacePhoenix, Jun 10, 2020 IP
  14. thetechguy1970

    thetechguy1970 Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #14
    I read through that. The problem is, Apache doesn't seem to read the htaccess file even if I put the AllowOverride All parameter in the vhost. Even though I put gibberish in the file, my site doesn't give a 500 error. So the permalink option doesn't work properly.
     
    thetechguy1970, Jun 10, 2020 IP
  15. RHS-Chris

    RHS-Chris Well-Known Member

    Messages:
    1,007
    Likes Received:
    35
    Best Answers:
    10
    Trophy Points:
    150
    #15
    Can you confirm your Apache configuration has the following line in it:
    
    # AccessFileName: The name of the file to look for in each directory
    # for additional configuration directives.  See also the AllowOverride
    # directive.
    #
    AccessFileName .htaccess
    
    Code (markup):
    Chris
     
    RHS-Chris, Jun 10, 2020 IP
  16. thetechguy1970

    thetechguy1970 Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #16
    Hi Chris.
    Yes, I can confirm that those lines are in my apache.conf file located at /etc/apache2/apache2.conf..
     
    thetechguy1970, Jun 10, 2020 IP
  17. RHS-Chris

    RHS-Chris Well-Known Member

    Messages:
    1,007
    Likes Received:
    35
    Best Answers:
    10
    Trophy Points:
    150
    #17
    You are going to have to go through all configuration files to see if there is a conflicting statement. Best way to do this is to enable mod_info, then only allow your IP to view it. These are the steps I took below on my test server (Ubuntu):
    • sudo a2enmod info
    • sudo service apache2 restart
    • apachectl -M (make sure info_module is loaded)
    • vim /etc/apache2/mods-enabled/info.conf
      • Edit the file to add your computers IP.
      • Example
        • Require ip 1.1.1.1
    • sudo service apache2 restart
    You should now be able to visit the following address (use your servers IP) and have all of the configuration listed:

    http://your.servers.ip.here/server-info
    Code (markup):
    Chris
     
    RHS-Chris, Jun 11, 2020 IP
  18. thetechguy1970

    thetechguy1970 Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #18
    This may be a conflict.
    
    In file: /etc/apache2/apache2.conf
      <Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
        : </Directory>
    
    Code (markup):
    Am I correct?
     
    thetechguy1970, Jun 11, 2020 IP
  19. RHS-Chris

    RHS-Chris Well-Known Member

    Messages:
    1,007
    Likes Received:
    35
    Best Answers:
    10
    Trophy Points:
    150
    #19
    No, that should not have any effect as you are calling out the other directory. To test though, comment out those lines, restart and check.

    Chris
     
    RHS-Chris, Jun 12, 2020 IP
  20. thetechguy1970

    thetechguy1970 Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #20
    Hi.
    Could this be the issue?
    
    In file: /etc/apache2/apache2.conf
      <Directory /var/www/>
        Options Indexes FollowSymLinks
       AllowOverride None
       Require all granted
        : </Directory>
    
    Code (markup):
     
    thetechguy1970, Jun 18, 2020 IP