需要有关 WordPress 中友好 URL 的帮助
我正在 WordPress 中创建一些自定义模板,并在 URL 中传递一些数据。
目前我的网址如下所示: http://www.mysite.com/designers/?id=43& ;name=designer+name
URL 包含设计师 ID 和设计师姓名。
我真的很想用这个: http://www.mysite.com/designers/designer+name/
我的永久链接结构设置为 /%category%/%postname%/
我的 .htaccess 文件如下所示:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
我查看了 http://codex.wordpress.org/Using_Permalinks,但不会变得更明智。
我有两个问题:
- 更改上述关于 SEO 的 URL 有什么意义
- 我怎样才能获得“漂亮”的 URL?
I'm creating som custom templates in Wordpress and I'm passing some data in the URL's.
Currently my URL looks like this:
http://www.mysite.com/designers/?id=43&name=designer+name
The URL contains designer ID and designer name.
I would really like to use this:
http://www.mysite.com/designers/designer+name/
My permalink structure is set to /%category%/%postname%/
My .htaccess file looks like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I've looked at http://codex.wordpress.org/Using_Permalinks, but not become any wiser.
I got two questions:
- Is there any point in changing the above URL regarding SEO
- How can I get the "pretty" URL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
史蒂文,一个非常有趣的话题。去年我在 WordPress 上的房地产项目中经历了这个过程。有很多方法可以对永久链接进行一些自定义,包括 WordPress 3.0 及更高版本中的所有新功能,但正如我所发现的,关键当然是对它们进行“硬编码”。
在 WordPress 中,它的完成方式与在 Apache 中的完成方式几乎相同,只是有一些例外。仔细阅读 WP_Rewrite 文章,它应该几乎可以解释所有内容。通过这种方法,我设法获得如下永久链接:
其中
country
和region
是一种分层的自定义分类法。我花了一段时间,但现在似乎工作正常,即使对核心代码进行了最新更改。Steven, quite an interesting topic. I went through it last year on my real estate project in WordPress. There are tonnes of ways to apply some customizations to your permalinks, including all the new features in WordPress 3.0 and above, but as I figured out, the key is of course to sort of "hard-code" them.
In WordPress it's done pretty much the same way as you would do it in Apache, only with a few exceptions. Read through the WP_Rewrite article, it should pretty much explain everything. With this approach I managed to get permalinks like this:
Where
country
andregion
are one custom taxonomy which is hierarchical. It took me a while but it seems to work fine now, even with the latest changes to the core code.