有问题的URL是:
- (不起作用) alltheragefaces/face/surprised-wut/
- (Works) alltheragefaces/face/surprised-wut
- (Doesn't work) alltheragefaces/face/surprised-wut/
- (Works) alltheragefaces/face/surprised-wut
我对这些类型的URL的.htaccess规则如下:
The .htaccess rule I have for these types of URLs looks like:
RewriteRule ^ face /(。 *)$ face.php?term = $ 1
如何使这两个URL都进入同一页面? / p>
What can I do to make both of these URLs to go to the same page?
推荐答案您可以使用以下代码:
RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)/$ /$1 [L,R=301]第一行说:如果它不是目录(因为后跟斜杠才有意义)。第二行说:重定向所有内容,从开始到结尾的斜线,再到结尾的所有内容,都没有结尾的斜线。
The first line says: "if it's not a directory" (because then a trailing slash would have meaning). The second line says: redirect everything from start to the trailingslash and end to everything that was in there, without the trailing slash.
放入您自己的 RewriteRule 在那里(在那个下面,而不是上面),因此在删除斜杠后,您的常规重定向仍然有效。
Put your own RewriteRule in there (below that one, not above) so your normal redirect still works after the trailing slash was removed.
显然也可以用于 / body / ,而不仅可以用于 / face / 。
(this one will obviously work for /body/ too, and not only for /face/.
更多推荐
斜杠末尾导致404,我可以使用htaccess进行修复吗?
发布评论