如何重定向父目录,而不是子目录?见下面我的具体问题。所有的帮助和任何帮助都是感激的!
亲本-
redirect 301 /community/whats-happening http://www.stapletondenver.com/whats-happening/ Child -
redirect 301 /community/whats-happening/celebrating-halloween-stapleton http://www.stapletondenver.com/whats-happening/celebrating-halloween-in-stapleton/ ,我尝试过其他几种选择,但都没有成功。见下文:
RewriteRule ^community/whats-happening/. /whats-happening/ [R=301,L]
RewriteRule ^community/whats-happening/(.*)$ /whats-happening/$1 [R=301,NC,L]
RewriteRule ^/?community/whats-happening/?$ http://www.stapletondenver.com/whats-happening/ [R=301]
RewriteRule ^community/whats-happening/(.*) http://stapletondenver.com/whats-happening/$1 [R=301,L]
RewriteRule ^community/whats-happening/(.*)/(.*)/? http://stapletondenver.com/whats-happening/$1/ [R=301,L]发布于 2015-01-09 00:59:41
这是因为你的第一次重定向。Redirect指令将所有子目录和文件重定向到,因此:
Redirect 301 /abcd http://domain.com/xyz手段
/abcd/ -> http://domain.com/xyz//abcd/1234/ -> http://domain.com/xyz/1234//abcd/1234/z.html -> http://domain.com/xyz/1234/z.html等。
如果只希望父目录重定向,请使用带有$结束字符的regex和$:
RedirectMatch 301 ^/community/whats-happening/?$ http://www.stapletondenver.com/whats-happening/
RedirectMatch 301 ^/community/whats-happening/celebrating-halloween-stapleton/?$ http://www.stapletondenver.com/whats-happening/celebrating-halloween-in-stapleton/https://stackoverflow.com/questions/27851475
复制相似问题