如何将 wordpress 中的下载 url 路径更改为 www.yoursite.com/download? [英] How to change download url path in wordpress to www.yoursite.com/download?

查看:22
本文介绍了如何将 wordpress 中的下载 url 路径更改为 www.yoursite.com/download?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图隐藏或缩短上传到 wp-content/uploads 文件夹的文件或图片的链接.默认情况下,在 WordPress 中,如果您上传图像、pdf 等并将其插入到帖子或页面中,它将具有如下链接:

I am trying to hide or shorten the link to files or picture uploaded to the wp-content/uploads folder. By default in WordPress if you upload and image, pdf, etc and insert it into a post or page it will have a link like this:

mysite.com/wp-content/uploads/2014/08/picture.jpg"

mysite.com/wp-content/uploads/2014/08/picture.jpg"

我想隐藏对我网站上所有 WP 文件夹的引用.我正在尝试找到一种方式,使 URL 显示为这样.

I want to hide the reference to all WP folders on my site. I am trying to find a way that the URL will display like this instead.

mysite.org/uploads/2014/08/picture.jpg"

mysite.org/uploads/2014/08/picture.jpg"

mysite.org/uploads/picture.jpg"

mysite.org/uploads/picture.jpg"

mysite.org/picture.jpg"

mysite.org/picture.jpg"

是否有插件或一些黑客可以让我隐藏wp-content"而不显示在我的网址中?

Is there a plugin or some hack that will let me hide the "wp-content" from showing up in my urls?

推荐答案

将此添加到您网站的 wp-config.php 文件中.

Add this to your wp-config.php file for your website.

define( 'UPLOADS', 'downloads' );

然后使用 FTP 或 RDP(或您访问服务器的任何方式),在 WordPress 站点的根目录中创建一个名为下载"的文件夹.

Then using FTP or RDP (or however you access your server), create a folder called "downloads" in the root directory of the WordPress site.

然后,您需要在 WordPress 管理员的设置">媒体"中取消选中将我的上传内容组织到基于月和年的文件夹中"选项框.

Then you need to uncheck the box for the "Organize my uploads into month- and year-based folders" option in Settings > Media of the WordPress admin.

注意:如果您在媒体库中已经有文件,那么如果您希望所有文件保持一致,则需要移动这些文件并更改对数据库中旧上传文件夹的所有引用.

Note: If you already have files in the media library, those will need to be moved over and all references to the old uploads folder in the database changed, if you want it all to be consistent.

这篇关于如何将 wordpress 中的下载 url 路径更改为 www.yoursite.com/download?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆