如何使用的.htaccess隐藏PARAMS中传递的url [英] How to hide params passed in url using .htaccess
本文介绍了如何使用的.htaccess隐藏PARAMS中传递的url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个特殊的情况,我的网站是像
I have a peculiar situation, my website is like
www.example.com/page.php?url=homepage
。我想使用.htaccess文件,使URL看起来像
. I am trying to use .htaccess file to make url look like
www.example.com/page/homepage/
还有通过隐藏的.php?URL =url中的一部分。这可能吗?请建议。
There by hiding the ".php?url=" part in the url. is this possible? please suggest.
推荐答案
试试这个:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
# /anything/anything -> anything.php?url=anything
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([A-Za-z0-9_])/([^/]*)$ /$1.php?url=$2 [L]
</IfModule>
如果在 page.php
文件名,将永远是相同的,那么像这样做:
If the page.php
filename will always be the same, then do it like this:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
# /page/anything -> page.php?url=anything
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^page/([^/]*)$ /page.php?url=$1 [L]
</IfModule>
这篇关于如何使用的.htaccess隐藏PARAMS中传递的url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文