• Resolved James Hall

    (@putarguygmailcom)


    For 13 years I have been storing my product brochure PDF’s in a folder that isn’t part of WordPress (created via FTP) in the root of the domain, but as of version 6.1 those hyperlinks ALL return a 404. Files are all there and path is correct.

    Is there a way to disable this new security feature?

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • function my_mod_rewrite_rules( $rules ) {
    
    	$search = '/RewriteBase.+/';
    
    	$replacement = $search . PHP_EOL . 'RewriteCond %{REQUEST_URI} !^/(pdf/.*)$';
      
    	$rules = preg_replace( $search, $replacement, $rules );
    
    	return $rules;
    
    }
    add_filter( 'mod_rewrite_rules', 'my_mod_rewrite_rules', 11, 1 );

    Hi! You’ll want to add code like this to your child theme functions.php file. It sounds like you can FTP, so you can do it that way. Or you can use a plugin like “Code Snippets” to add it. This filter-hooked function modifies the .htaccess file the way WordPress suggests it be done. Look closely for the “pdf” inside the code to better understand what is happening.

    Thread Starter James Hall

    (@putarguygmailcom)

    I really appreciate your help Little Package. However, that snippet doesn’t seem to do anything. Cleared cache also. I just added the code to my child theme’s function.php file through the ‘Theme Editor’. I have a dedicated server so I can edit my htaccess file directly as well, but why is WordPress so secure that I can’t directly access *my own* folder in the same root directory?

    OVERKILL on the security updates 🙁

    Good greif

    Can you share a screenshot of the code in your child theme functions.php file?

    You can try this slight adjustment, also. I “guessed” that the directory you are talking about is “pdf” is that right? Code is working on my installation. It’s not a security thing that I’m aware of… can you share what makes you keep saying that?

    function my_mod_rewrite_rules( $rules ) {
    
    	$search = '/RewriteBase.+/';
    
    	$replacement = $search . PHP_EOL . 'RewriteCond %{REQUEST_URI} !^/(pdf/.*|pdf)$';
      
    	$rules = preg_replace( $search, $replacement, $rules );
    
    	return $rules;
    
    }
    add_filter( 'mod_rewrite_rules', 'my_mod_rewrite_rules', 11, 1 );

    Thread Starter James Hall

    (@putarguygmailcom)

    Thank you so much! In asking for a screenshot I realized my error. I’m adding a new skin to an old site and didn’t have that folder in my test site root 🙁

    Stupid mistake. Thanks for helping me see it!

    Great. I was still going to ask again what made you think that a WP security update caused this, because we’re lacking evidence on this end. If this ran for you BEFORE 6.1 without an .htaccess edit or use of a plugin, I’d like to know how. This has been a “limitation” of WordPress for a very long time and has nothing to do with recent updates. If you type in yoururl.com/pdf, WordPress is naturally going to look for a WordPress page called “pdf” (or post, depending on permalinks) because that is what WordPress does.

    I want to clarify this with you, because your assertion does not seem well-founded and could lead other people astray.

    Thread Starter James Hall

    (@putarguygmailcom)

    Because the file I was trying to link to was on the “primary” domain, but I was working on a backup copy of the website so I could deploy a new theme. The primary domain is on the same dedicated server so the only difference (I thought) was the version of WordPress. But I was linking to the test domain where there was no /pdf/ folder. Like I said, rookie mistake~

    I got that from your last message. I was just clarifying to other people who might read this support thread that this issue has not much to do with 6.1 update or WordPress “security.”

    I’m glad you’re sorted! Take care.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Cannot Internally Link to Non-WordPress Folder’ is closed to new replies.