.htaccess重写重定向的url [英] .htaccess rewrite redirected url
问题描述
我已将所有.html页面重定向到带有get参数的process.php,现在我想清除查询url。
我已经重定向了。 / p>
RewriteEngine on
RewriteRule ^([^ /] *)/(。* \.html)/ Site / process.php?dir = $ 1& page = $ 2 [R = 301,L]
这样的网址。
http://localhost/Site/process.php?dir = Directory& page = page.html
我想将此网址清理回原始网址,并且仍然可以发布取得参数。
http://localhost/Site/Directory/page.html
我已经尝试过了。
RewriteEngine on
RewriteRule ^([^ /] *)/(。* \.html)/Site/process.php?dir=$1&page=$2 [R = 301,L]
RewriteRule ^ Site / $ 1 /$2([^/.]+)/?$ [L]
但它什么都不做。
请参阅并提出任何可能的解决方法。
谢谢。
编辑
这些html页面实际上并不存在,只是页面中的链接,我想处理这些链接,使用php和htaccess使数据库中的页面保持原封不动,这可以做到。
如果您只想在地址栏中留下html部分来制作漂亮的网址,只需将 [R]
标志,并放弃第二条规则。重定向将发生在服务器上,但浏览器仍将具有 .html
URL。
I have redirected my all .html pages to process.php with get parameter, now i want to clean the query url.
I have redirected like this.
RewriteEngine on
RewriteRule ^([^/]*)/(.*\.html) /Site/process.php?dir=$1&page=$2 [R=301,L]
This gives url like this.
http://localhost/Site/process.php?dir=Directory&page=page.html
I want to clean this url back to original url like this and still be able to post get parameter.
http://localhost/Site/Directory/page.html
I have tried like this.
RewriteEngine on
RewriteRule ^([^/]*)/(.*\.html) /Site/process.php?dir=$1&page=$2 [R=301,L]
RewriteRule ^Site/$1/$2([^/.]+)/?$ [L]
But it does nothing.
Please see and suggest any possible way to this.
Thanks.
Edit
These html pages actually don't exist, just the link in pages, i want to process these link to make page from database using php and htaccess keeping url intact, can this be done.
If you're just wanting to leave the "html" part in the address bar to make "pretty URLs", just leave off the [R]
flag, and drop the 2nd rule. The redirect will happen on the server, but the browser will still have the .html
URL.
这篇关于.htaccess重写重定向的url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!