[英]URL rewriting- How can I turn example.com/pageid.php?id=12 to example.com/full-title
I want to make my pages search engine friendly and it also looks better that example.com/pageid.php?id=12 我想让我的页面搜索引擎友好,并且example.com/pageid.php?id=12也看起来更好
I have pages different pages like showUser.php showLocation.php and I want all these to be rewritten. 我有不同的页面,例如showUser.php showLocation.php ,我希望所有这些页面都被重写。
Wo'nt mod_rewrite slow down my app a little bit? mod_rewrite会使我的应用程序变慢一点吗?
您需要看一下mod_rewrite(只要您的主机支持它)-这是一篇有关该主题的不错的博客文章 。
In your particular example, mod_rewrite
could be set up something like this: 在您的特定示例中,可以将
mod_rewrite
设置如下:
# .htaccess
RewriteEngine on
RewriteRule ^/([\w-]+)$ /page.php?title=$1
Now, a request to /full-title
would resolve to page.php
and $_GET['title']
would hold the value 'full-title'
. 现在,对
/full-title
的请求将解析为page.php
而$_GET['title']
将保留值'full-title'
。
(Most web frameworks (such as Symfony, Django etc.) allow for customizable URL routing rules which do not require you to hardcode rewrite rules in your .htaccess
file.) (大多数Web框架(例如Symfony,Django等)允许使用可自定义的URL路由规则,这些规则不需要您对
.htaccess
文件中的重写规则进行硬编码。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.