字preSS改写后的画廊图片的网址 [英] Wordpress rewrite post gallery image url

查看:107
本文介绍了字preSS改写后的画廊图片的网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在默认情况下,我有一个附件页面网址:

By default, I have an attachment page URL:

http://example.lt/photo/juokingi-pokalbiai-22-nuotraukos/attachment/221/

我想有:

http://example.lt/photo/juokingi-pokalbiai-22-nuotraukos/gallery/221/

http://example.lt/photo/juokingi-pokalbiai-22-nuotraukos/221/

http://example.lt/photo/juokingi-pokalbiai-22-nuotraukos/img_name

是否有可能重写附加的图片网址是什么?

Is it possible to rewrite the attached images URL?

在固定链接设置,我不能只为标签和类别设置额外的网址,怎么样的附件?

In permalinks settings, I cant set additional URL only for tags and category, how about attachments?

推荐答案

添加到您的的.htaccess 在Web根 / 目录

Add this to your .htaccess in your web root / directory

RewriteEngine on
RewriteBase /

# for /photo/juokingi-pokalbiai-22-nuotraukos/gallery/221/
RewriteRule ^(.*)/gallery/(\d+)/?$ $1/attachment/$2 [NC,L]

# if "photo/juokingi-pokalbiai-22-nuotraukos" path is static followed by id
RewriteRule ^(photo/juokingi-pokalbiai-22-nuotraukos)/(\d+)/?$ $1/attachment/$2 [NC,L]

除非,图像名字也包含附件的ID;处理一个URL如 /照片/ juokingi-pokalbiai-22-nuotraukos / img_name 将是不可能的。

这篇关于字preSS改写后的画廊图片的网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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