• Resolved andy_moyle

    (@andy_moyle)


    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?

Viewing 12 replies - 1 through 12 (of 12 total)
  • 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… ??

    Thread Starter andy_moyle

    (@andy_moyle)

    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

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

    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..

    Thread Starter andy_moyle

    (@andy_moyle)

    It is in the same directory! D’oh!

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

    [1] – https://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..

    Thread Starter andy_moyle

    (@andy_moyle)

    Oops – helps if I save the changes before uploading.

    Removing authorisation makes it work

    Now how do I get the auth working?

    Thread Starter andy_moyle

    (@andy_moyle)

    Apache 2.2.4

    been trying different quotes etc to!

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

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

    Thread Starter andy_moyle

    (@andy_moyle)

    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
    Thread Starter andy_moyle

    (@andy_moyle)

    Thanks for the help by the way!

    Glad to hear you got it working… and you’re welcome… ??

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘htaccess rewite giving 401 on a static file’ is closed to new replies.