简体   繁体   English

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

[英]htaccess rewrite working but not all rules

These are my rules in .htacces file. 这些是我在.htacces文件中的规则。

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]

All rules are working fine but the last one. 所有规则都工作正常,但是最后一个规则。 post-images.php pages is perfectly working if i directly use the url but not with rewriteurl. 如果我直接使用url而不是rewriteurl,则post-images.php页面将完全正常工作。 its showing 其显示

Not Found 未找到

The requested URL /PostImages/135 was not found on this server. 在此服务器上找不到请求的URL / PostImages / 135。

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. 此外,尝试使用ErrorDocument处理请求时遇到404 Not Found错误。

Mmh, I tried to edit your RewriteRule and edited it to make this rule: 嗯,我尝试编辑您的RewriteRule并对其进行编辑以使其符合以下规则:

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

It works for me, would u mind trying it? 它对我有用,您介意尝试吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM