请注意RedirectMatch
是mod_alias,而不是mod_rewrite。当来自两个模块的指令被应用到相同的URI时,这两个模块并不总是很好地互相配合。没有任何想法,您的网站是如何设置,有没有办法回答你的问题,但你可以通过尝试这样的事情* mod_rewrite的*:
RewriteEngine On
# Check that the request isn't for an existing resource
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Check that the request isn't for the new store
RewriteCond %{REQUEST_URI} !^/newstore
# redirect to the new store
RewriteRule^/newstore/ [L,R]
这里的理由是,如果要求不是现有页面,图像,脚本,这可能会导致404,如果该请求不适用于/newstore
文件夹中的动态网站,则我们将其重定向到/newstore/
文件夹。
但就像我说的,你有一些东西RedirectMatch
指令和mod_alias并不总是与mod_rewrite很好玩。你可能需要将它们全部转换成重写规则,但它可能没有必要。例如:
RedirectMatch 301 ^/old-path/old-page.html$ /newstore/?page=123
将转化:
RewriteRule ^/old-path/old-page.html$ /newstore/?page=123 [L,QSA,R=301]
所有这些重写规则**必须之前上面说的规则重定向所有404对/ newstore *。因为这是一个“万无一失”的规则,就像是最后的手段,它需要在所有常规重定向之后。
你能证明你有什么吗?这可能会使回答更容易 –
对不起,由于我的代表到目前为止我不能发布任何额外的链接:(@JonLin似乎是在正确的轨道上,但 –
你可以编辑.htaccess文件到问题(如果它仍然是必要的。) –