【问题标题】:URL Rewrite to allow Periods for DomainsURL 重写以允许域的句点
【发布时间】:2012-06-18 14:33:15
【问题描述】:

我的网站上有某些类别用于网站或域,并且希望能够在网址中完整显示域,例如 amazon.com (domain.com/category/amazon.com)

目前,当我使用 Wordpress 时,默认情况下,所有多余的字符都会转换为连字符。 (domain.com/category/amazon-com

如何为某些域扩展名(.co.uk、.com、net 等)创建重写规则来重写这些 url,使它们与句点一起显示?

我当前的 htacces 包含以下重写规则:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

【问题讨论】:

    标签: wordpress .htaccess mod-rewrite url-rewriting rewrite


    【解决方案1】:

    您可以尝试为sanitize_title() 函数编写过滤器。这也向您展示了 . 在 wordpress 函数中的替换位置。 http://core.trac.wordpress.org/browser/tags/3.4/wp-includes/formatting.php#L972

    【讨论】:

    • 谢谢尼克 - 我写了一个可以工作的小过滤器,但我想把它限制在类别 URL 上。目前它也允许过滤实际的帖子标题:function dashes_to_periods_com( $title ){ return str_replace( '-com', '.com', $title ); } add_filter( 'sanitize_title', 'dashes_to_periods_com' );
    • 您可能能够连接到 create_category 操作以仅应用您的过滤器。我不确定会先调用哪个物流,但值得一试。
    猜你喜欢
    • 1970-01-01
    • 2011-07-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-22
    • 2013-12-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多