开发者

How can I use friendly/rewritten urls in php?

I have problem to encrypt the url.

example

existing url= www.domainname/search.php?key=bo开发者_如何学编程oks&type=title&Submit=search

i want to encrypt this url.

encrypt url= www.domainname/keword-keyword-keyword.html

in this form...

can any one solve my problem.. i will be greatfull to him or her


If you're using PHP, you may well be on an Apache server - in which case you can use Apache's mod_rewrite to provide restful URIs to your visitors.

Here is a short example:

RewriteEngine on
RewriteRule ^Search/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ search.php?key=$1&type=$2&term=$3 [L,NC]

This would translate

http://www.domainname/Search/books/title/Mission%20Impossible/

Into

http://www.domainname/search.php?key=books&type=title&term=Mission%20Impossible

The [L] means no further rules would be evaluated The [NC] makes this case-insensitive (so "Search" and "search" would both work)


This is called Friendly URL: http://www.google.com/search?q=friendly+URL

  • http://www.petefreitag.com/item/503.cfm
  • http://articles.sitepoint.com/article/search-engine-friendly-urls
  • http://www.seoconsultants.com/articles/1000/urls.asp


It is also possible to use a PHP file as common part of the path and parse the request URI yourself. E.g.

http://www.example.com/index.php/books/AliceInWonderland

In this case, index.php could parse the $_SERVER['REQUEST_URI'].

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜