admin管理员组

文章数量:1024054

I'm currently using a plugin that generates a PDF for customers but the URL is way too long. For eg - .pdf. Here's the specific code from the plugin relating to this:

$upload = wp_upload_dir();
$upload_dir = $upload['basedir'];
$upload_dir = $upload_dir . '/pdfuploads';
if (! is_dir($upload_dir)) {
  mkdir( $upload_dir, 0755 );
  $file = fopen($upload_dir.'/index.html',"wb");
  echo fwrite($file,"Silence is golden.");
  fclose($file);
}

The PDF then generates in:

=> get_home_url().'/wp-content/uploads/pdfuploads/'
$attachments[0] = $upload_dir.'/pdfuploads/'

I want to shorten this URL so it reads something like - .pdf. I tried adding RewriteRule ^wp-content/uploads/pdfuploads/(.*)$ /pdfs/$1 [R=301,NC,L] to htaccess but that didn't move the files over. Is there a quick fix for this via htaccess or functions? Otherwise, if I need to edit the plugin's PHP files myself, what do I need to change in the above code?

I'm currently using a plugin that generates a PDF for customers but the URL is way too long. For eg - .pdf. Here's the specific code from the plugin relating to this:

$upload = wp_upload_dir();
$upload_dir = $upload['basedir'];
$upload_dir = $upload_dir . '/pdfuploads';
if (! is_dir($upload_dir)) {
  mkdir( $upload_dir, 0755 );
  $file = fopen($upload_dir.'/index.html',"wb");
  echo fwrite($file,"Silence is golden.");
  fclose($file);
}

The PDF then generates in:

=> get_home_url().'/wp-content/uploads/pdfuploads/'
$attachments[0] = $upload_dir.'/pdfuploads/'

I want to shorten this URL so it reads something like - .pdf. I tried adding RewriteRule ^wp-content/uploads/pdfuploads/(.*)$ /pdfs/$1 [R=301,NC,L] to htaccess but that didn't move the files over. Is there a quick fix for this via htaccess or functions? Otherwise, if I need to edit the plugin's PHP files myself, what do I need to change in the above code?

本文标签: phpMove plugin upload folder from mywebsitecomwpcontentuploadspdfuploads to mywebsitecompdfs