简体   繁体   English

使用.htaccess时出现404 Not Found错误

[英]404 Not Found error while using .htaccess

I have this link: 我有这个链接:

<a href="admin.php?page=buyingreport">Buying Report</a>

To get a pretty URL, I've changed it to: 要获得漂亮的网址,我已将其更改为:

<a href="admin/buyingreport">Buying Report</a>

And this is my whole .htaccess: 这是我的全部.htaccess:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^mysite [nC]
RewriteRule ^/?$ "http\:\/\/www\.mysite\.com\/" [R=301,nC]

RewriteRule ^([^/.]+)$ $1.php [L]

RewriteRule ^admin/([a-z]+)$ admin.php?page=$1 [L]

I always get 404 Not Found error "The requested URL /admin/buyingreport.php was not found on this server". 我总是得到404 Not Found错误“在此服务器上找不到请求的URL /admin/buyingreport.php”。 Why was it redirect me to buyingreport.php? 为什么它会将我重定向到purchasereport.php?

The .htaccess file doesn't seem to work. .htaccess文件似乎不起作用。 Is there anything wrong with it? 它有什么问题吗? Or maybe with my link? 或者也许是我的链接?

Anybody can help me, please? 有人可以帮帮我吗?

This works perfectly 这非常有效

RewriteEngine On
RewriteRule ^admin/([a-zA-Z0-9]+)$ admin.php?id=$1 [QSA]

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

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