我该怎么重写呢
有人能重写这个网址吗?
http://localhost/display_news_cat.php?news_cat_id=14&p=2
至
http://localhost/display_news_cat/14/2
谢谢
发布于 2011-01-04 19:16:53
假设您已经安装了重写模块,您可以将以下代码放入您的虚拟主机中:
RewriteEngine打开
RewriteRule /newsdev/news /newsdev/news.php L
有关RewriteRule的更多信息,请查看此站点:http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule
但我怀疑这是最好的方法。对于这些简单的事情,重写模块通常不是最有效的方法。这取决于你想要重写的其他复杂的东西。
发布于 2011-01-04 19:15:32
您可以使用.htaccess文件来完成此操作
将其放在.htaccess文件中,并将其放在站点的根目录下apache必须启用mod-rewrite
RewriteEngine on
RewriteRule ^news.php news [QSA,L]对所有文件尝试此操作
RewriteEngine on
RewriteRule ^(a-zA-Z0-9).php $1 [QSA,L]发布于 2011-01-04 19:13:43
使用mod_rewrite
http://www.easymodrewrite.com/example-extensions
您需要使用站点根目录中的.htaccess文件...如果它不在那里,你将不得不创建一个。
https://stackoverflow.com/questions/4592920
复制相似问题