• Hey mates. I’ve been looking for a code to hide the file extensions from URLs and I came across this one:

    <IfModule mod_rewrite.c>
    ## Go Daddy servers need the Options -MultiViews code below
    Options -MultiViews
    
    RewriteEngine On
    RewriteBase /
    
    # To externally redirect /dir/foo.php to /dir/foo
    RewriteCond %{REQUEST_METHOD} !POST
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
    RewriteRule ^ %1 [R,L,NE]
    
    ## To internally redirect /dir/foo to /dir/foo.php
    RewriteCond %{REQUEST_FILENAME}.php -f [NC]
    RewriteRule ^ %{REQUEST_URI}.php [L]
    </IfModule>

    This .htaccess code was working beautifully until I found out that for some reason this was blocking admin features in my admin account, meaning I couldn’t activate/deactivate plugins, add/edit/delete users and so on. So I was forced to remove the .htaccess file and now I have the .php extensions back in my URLs. Eg. I currently have myexample.com/contact.php whereas I’d rather have myexample.com/contact.

    Is there a way of hiding the extensions from my URLs without losing my WP admin capabilities? Cheers.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Your problem will be because you’re not using the standard .htaccess file. What I would recommend is going back to your initial issue – the blocking of admin functions – and resolve that. It must be a screwed .htaccess to prevent some features of admin and not others.

    Can you post up what your original .htaccess looked like?

    Thread Starter Adriano Marques

    (@adrianomarques)

    Hi dartiss. Thanks for the response.

    There wasn’t any .htaccess before the one I uploaded into my server actually. This is the very first one. I just wanted to hide the extensions in the URLs… ??

    You need to go into Settings -> Permalinks and set up a permalink structure. That should create the required .htaccess.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘.htaccess blocking admin features for admin users’ is closed to new replies.