Php .htaccess重写重定向的url

Php .htaccess重写重定向的url,php,html,mod-rewrite,Php,Html,Mod Rewrite,我已经用get参数将我的所有.html页面重定向到process.php,现在我想清理查询url 我已经像这样重新定向了 RewriteEngine on RewriteRule ^([^/]*)/(.*\.html) /Site/process.php?dir=$1&page=$2 [R=301,L] http://localhost/Site/process.php?dir=Directory&page=page.html RewriteEngine on Rewrite

我已经用get参数将我的所有.html页面重定向到process.php,现在我想清理查询url

我已经像这样重新定向了

RewriteEngine on
RewriteRule ^([^/]*)/(.*\.html) /Site/process.php?dir=$1&page=$2 [R=301,L]
http://localhost/Site/process.php?dir=Directory&page=page.html
RewriteEngine on
RewriteRule ^([^/]*)/(.*\.html) /Site/process.php?dir=$1&page=$2 [R=301,L]
RewriteRule ^Site/$1/$2([^/.]+)/?$ [L]
这个url是这样的

RewriteEngine on
RewriteRule ^([^/]*)/(.*\.html) /Site/process.php?dir=$1&page=$2 [R=301,L]
http://localhost/Site/process.php?dir=Directory&page=page.html
RewriteEngine on
RewriteRule ^([^/]*)/(.*\.html) /Site/process.php?dir=$1&page=$2 [R=301,L]
RewriteRule ^Site/$1/$2([^/.]+)/?$ [L]
我想像这样将这个url清理回原始url,并且仍然能够发布get参数

http://localhost/Site/Directory/page.html
我试过这样做

RewriteEngine on
RewriteRule ^([^/]*)/(.*\.html) /Site/process.php?dir=$1&page=$2 [R=301,L]
http://localhost/Site/process.php?dir=Directory&page=page.html
RewriteEngine on
RewriteRule ^([^/]*)/(.*\.html) /Site/process.php?dir=$1&page=$2 [R=301,L]
RewriteRule ^Site/$1/$2([^/.]+)/?$ [L]
但它什么也没做

请查看并提出任何可能的解决方法

谢谢

编辑


这些html页面实际上不存在,只是页面中的链接,我想使用php和htaccess处理这些链接,使数据库中的页面保持url完整,这可以做到吗。

回答
,并且仍然能够发布get参数
部分(将完整的原始查询字符串传递给脚本):

RewriteRule some.html some other.php?%{QUERY\u STRING}[L]


可能会有帮助。

如果您只是想在地址栏中留下“html”部分来创建“漂亮的URL”,只需去掉
[R]
标志,然后删除第二条规则。重定向将在服务器上发生,但浏览器仍将具有
.html
URL。

哪个目录是docroot?地点?或者更高的站点?如果您保留原始URL并将资源以静默方式映射到php文件,那么您也在这样做。此时,您正在将“漂亮”URL重定向到“丑陋”资源地址,但现在您希望保留此资源地址,但再次显示“漂亮”URL,这将返回到起点。@Felipe Alameda A-这些html页面实际上不存在,只是页面中的链接,我想处理这些链接,使用php和htaccess从数据库创建页面,保持url完整,这可以做到吗。您在
@
和我的用户名之间留了一个空格,所以我没有收到您的评论。我在这里有点迷茫,但一般来说,当浏览器显示一个“漂亮”的URL时,资源(脚本)可以映射到一个地址,如果你是这样问的话。它可以工作
RewriteRule^([^/]*)/(.\.html)/Site/process.php?dir=$1&page=$2[L]
非常感谢。感谢您的反馈,很高兴我能提供帮助!