htaccess使用子目录重定向作为变量

时间:2015-08-25 17:37:00

标签: .htaccess redirect

我尝试做的是将example.com/author/authorname/重定向到example.com/author/authorname/page/1/,以便分页在页面的初始加载时更有效地工作。

目前我得到了

RedirectMatch /example/author/(.*) http://localhost:8888/example/author/(.*)/page/1/

我试图使用通配符变量,但似乎不起作用。在(。*)的第一个位置,我需要将该值存储为变量,并在重定向位置的类似位置使用完全相同的名称。

1 个答案:

答案 0 :(得分:0)

尝试:

RedirectMatch ^/example/author/([^/]+)/?$ /example/author/$1/page/1

或者如果你已经有了mod_rewrite规则,你应该坚持:

RewriteEngine On
RewriteRule ^example/author/([^/]+)/?$ /example/author/$1/page/1 [L,R]