Cannot Internally Link to Non-WordPress Folder

[ad_1]

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.

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 );

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!

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer