htaccess的URL重写 - 请求的URL在服务器上未找到 [英] htaccess URL rewrite - requested URL not found on server

查看:346
本文介绍了htaccess的URL重写 - 请求的URL在服务器上未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

具有将URL重写运行的问题,但服务器将不显示内容。我的.htaccess文件是

Having an issue where the URL rewrite is running but the server will not display the contents. My .htaccess file is

    RewriteEngine On
    RewriteBase /
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /project\.php [NC]
    RewriteCond %{QUERY_STRING} id=([0-9]+) [NC]
    RewriteRule . project-%1.html? [R=301]

感谢您的帮助!

Thanks for your help!

编辑:对不起,这里是一些更多的信息

Sorry, here is some more info!

我想重写

    www.siteurl.co.uk/project.php?id=82

    www.siteurl.co.uk/project-82.html

在code在的.htaccess重写URL完美,但页面不显示。我收到了

The code in the .htaccess rewrites the URL perfectly but the page does not display. I get a

    404 The requested URL /project-82.html was not found on this server. 

我希望帮助!

I hope that helps!

推荐答案

您只需要一半的解决方案,创造了pretty的网址。现在缺少的是另一半,送pretty的URL来进行处理的应用程序,如下

You only have one half of the solution, creating the pretty urls. What is missing is the other half, sending the pretty urls to an application for processing as below

RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /project\.php [NC]
RewriteCond %{QUERY_STRING} id=([0-9]+) [NC]
RewriteRule . project-%1.html? [R=301]

#you need this rule to process your www.siteurl.co.uk/project-82.html request
RewriteRule ^project-([0-9]+)\.html$ project.php?id=$1 [L,NC,QSA]

这篇关于htaccess的URL重写 - 请求的URL在服务器上未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆