POST 上的 .htaccess 重写错误
我在子文件夹“blog/”中安装了一个 Drupal 站点。
它是几个月前在根目录中的,所以我必须创建一个重写规则以将旧网址重定向到新路径。
这工作得很好,只是它不适用于节点编辑。当我更新内容(POST 方法)时,我总是在主站点(根文件夹中的站点)上看到 404 页面。
这些是我在根 .htaccess 中的规则
RewriteRule ^content/(.*)$ http://www\.mysite\.com/blog/content/$1 [R=301,L]
RewriteRule ^page/(.*)$ http://www\.mysite\.com/blog/page/$1 [R=301,L]
RewriteRule ^sites/(.*)$ http://www\.mysite\.com/blog/sites/$1 [R=301,L]
RewriteRule ^node/(.*)$ http://www\.mysite\.com/blog/node/$1 [R=301,L]
RewriteRule ^blog/(.*)$ http://www\.mysite\.com/blog/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^mysite\.com$ [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301]
,这些是子文件夹 .htaccess 中的规则,
RewriteCond %{HTTP_HOST} ^mysite\.com$ [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]
我认为与 Drupal 本身无关,但在 RewriteRule 中存在问题。
有人可以给我建议吗?
I have a Drupal site installed in a subfolder "blog/".
It was in the root months ago, so I had to create a rewrite rule to redirect old url to the new path.
This works fine, except that it doesn't work for node edit. When I update a content (POST method), I always get 404 page on the main site (the one in the root folder).
These are my rules in the root .htaccess
RewriteRule ^content/(.*)$ http://www\.mysite\.com/blog/content/$1 [R=301,L]
RewriteRule ^page/(.*)$ http://www\.mysite\.com/blog/page/$1 [R=301,L]
RewriteRule ^sites/(.*)$ http://www\.mysite\.com/blog/sites/$1 [R=301,L]
RewriteRule ^node/(.*)$ http://www\.mysite\.com/blog/node/$1 [R=301,L]
RewriteRule ^blog/(.*)$ http://www\.mysite\.com/blog/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^mysite\.com$ [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301]
and these are the ones in the subfolder .htaccess
RewriteCond %{HTTP_HOST} ^mysite\.com$ [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]
I don't think is something related to Drupal itself, but it's something wrong in the RewriteRule.
Can someone give me an advice?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过使用完整的 http:// URL 和
R=301
,您可以告诉服务器将重定向标头发送到浏览器,而不是进行内部重写。 POST 变量不会被重新发送到新位置。如果您希望 POST 变量通过,则需要进行内部重写(假设重写目标与 .htaccess 文件位于同一服务器上)。不过,这些不会更改浏览器栏中的 URL - 不确定这是否是您想要的。
By using full http:// URLs and
R=301
, you are telling the server to send redirect headers to the browser instead of doing an internal rewrite. POST variables will not be re-sent to the new location.If you want POST variables to get through, you need to do internal rewrites (assuming that the rewrite target is on the same server as your .htaccess file). Those won't change the URL in the browser bar, though - not sure whether that is what you want.