重写 URL 在 .htaccess drupal 8 中不起作用

Rewrite URL not working in .htaccess drupal 8

我已经在 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/ [R=301,L]

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

谢谢。

您可以使用:

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= [L,QSA,NC]