WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] htaccess rewite giving 401 on a static file (13 posts)

  1. andy_moyle
    Member
    Posted 3 years ago #

    I have custom permalinks so my .htaccess is WP generated and looks like this...

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    AuthType Basic
    AuthName "Booking Logs"
    AuthUserFile "/home/****/.htpasswds/.htpasswd"
    <FILES "e.php">
    require valid-user
    </FILES>

    I have *** out my address!
    I have a php script that handles a postback in my root
    e.php

    And Worpdress gives it a 401 error when I tried to go though myself (permissions 644 and 755 both cause a fail...)

    What is wrong?

  2. Mark / t31os
    Moderator
    Posted 3 years ago #

    I tend to find rules don't always work when placed after the WordPress rules (not that i do much rewriting)..

    Try placing your auth rules before the WordPress stuff..

    Just to chuck a suggestion in... ;)

  3. andy_moyle
    Member
    Posted 3 years ago #

    No! That's not the issue!

    Removing my authorisation request makes no odds.

    Somehow htaccess is not working out that e.php is a file and thus not rewriting it

  4. kahigiso
    Member
    Posted 3 years ago #

    [moderated] Please create a thread for your own support requests.

  5. Mark / t31os
    Moderator
    Posted 3 years ago #

    Is the e.php file in the same directory as the .htaccess file? If not, then i'd guess you need the path in the FILES line..

    Else, you can always just place a seperate .htaccess file in the directory where that file resides.

    I'm no apache expert of course, but that would be my assumption..

  6. andy_moyle
    Member
    Posted 3 years ago #

    It is in the same directory! D'oh!

  7. Mark / t31os
    Moderator
    Posted 3 years ago #

    What version of Apache are you running? You'll need at least 1.2 to use the FILES directive.

    [1] - http://httpd.apache.org/docs/1.3/mod/core.html#files

    Examples [1] would appear to indicate that quotes are used for matching files that match a pattern, and no quotes when matching a singular file (though it may just be written that way - maybe it makes a difference).

    I'm just throwing ideas in..

  8. andy_moyle
    Member
    Posted 3 years ago #

    Oops - helps if I save the changes before uploading.

    Removing authorisation makes it work

    Now how do I get the auth working?

  9. andy_moyle
    Member
    Posted 3 years ago #

    Apache 2.2.4

    been trying different quotes etc to!

  10. Mark / t31os
    Moderator
    Posted 3 years ago #

    I'm more a PHP guy, so outside of my comfort zone..

    Have you run over the howto docs?
    http://httpd.apache.org/docs/2.0/howto/auth.html

  11. andy_moyle
    Member
    Posted 3 years ago #

    Sorted. It needed "ErrorDocument 401 default" a WP requirement!

    ErrorDocument 401 default
    AuthType Basic
    AuthName "restricted area"
    AuthUserFile /home/***/.htpasswds/.htpasswd
    <FilesMatch "e.php">
    require valid-user
    </FilesMatch>
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
  12. andy_moyle
    Member
    Posted 3 years ago #

    Thanks for the help by the way!

  13. Mark / t31os
    Moderator
    Posted 3 years ago #

    Glad to hear you got it working... and you're welcome... :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.