【问题标题】:Rewrite URL not working in .htaccess drupal 8重写 URL 在 .htaccess drupal 8 中不起作用
【发布时间】:2016-10-18 13:27:06
【问题描述】:

我已经在一个 drupal 8 视图块中成功实现了分页。 现在它为我生成以下 URL:

http://tommiecrawford.local/node?page=1

但我不想要这个。

我想为我的分页链接提供以下网址。

http://tommiecrawford.local/blog/page/1

http://tommiecrawford.local/blog/page/2

http://tommiecrawford.local/blog/page/3

等等。

我已经用 htaccess 试过了,但它不适用于以下配置:

RewriteCond %{THE_REQUEST} page=$

RewriteRule . http://tommiecrawford.local/blog/page/$1 [R=301,L]

是否有针对此的模块或修复程序?

谢谢。

【问题讨论】:

  • 您的服务器是否允许您在 htaccess 中覆盖其配置?否则,您的 htaccess 甚至不会被考虑
  • 是的,服务器允许覆盖配置 Yann

标签: .htaccess drupal drupal-8


【解决方案1】:

你可以使用:

RewriteEngine on

# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} \s/+node\?page=([^\s&]+) [NC]
RewriteRule ^ /blog/page/%1? [R=302,L,NE]

# internal forward from pretty URL to actual one
RewriteRule ^blog/page/(.+?)/?$ /node?page=$1 [L,QSA,NC]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-03
    • 2014-08-08
    • 2011-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多