htaccess重写工作但不是所有规则

问题描述 投票:0回答:1

这些是我在.htaccess文件中的规则。

Options -MultiViews

# Turn Rewrite Engine On
RewriteEngine on

# Rewrite for login.php
RewriteRule ^Login login.php [NC,L]

# Rewrite for myaccount.php
RewriteRule ^Myaccount myaccount.php [NC,L]

# Rewrite for index.php
RewriteRule ^Home index.php [NC,L]    

# Rewrite for post-images.php?post=xxxx
 RewriteRule ^Postimages/([0-9a-zA-Z_-]+) post-images.php?post=$1 [NC,L]

所有规则都运行正常,但最后一个。 post-images.php页面完全有效,如果我直接使用网址而不是重写网页。它的表现

未找到

在此服务器上找不到请求的URL / PostImages / 135。

此外,尝试使用ErrorDocument处理请求时遇到404 Not Found错误。

php .htaccess url-rewriting
1个回答
1
投票

嗯,我试着编辑你的RewriteRule并编辑它来制定这个规则:

RewriteRule ^Postimages/(.*)$ http://www.yourwebsite.com/post-images.php?post=$1 [R=301,L]

它对我有用,你会介意尝试吗?

© www.soinside.com 2019 - 2024. All rights reserved.