php的动态URL如何静态化?

webeidolon 2010-06-18 06:58:50
php有页面是带有问号(?)的网址如(http://localhost/ctdeb/iteminfo.php?id=82),这样的网址不利于与搜索引擎抓取,请教大家如何让带有问号的URL静态化(URLrewrite),听说用什么dll可以实现?具体怎么回事?如哪位朋友有相关的PHP的dll麻烦上传。
...全文
735 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
webeidolon 2010-06-30
  • 打赏
  • 举报
回复
太感谢大家,问题解决解决了,我内牛满面。
#15楼 dingsongtao 朋友,你帮了我不少,感激你啊!
e3e4e7 2010-06-30
  • 打赏
  • 举报
回复
vvvvvvvvvvvvvvvvvvvv
kyzy_yy_pm 2010-06-30
  • 打赏
  • 举报
回复
LZ说的是伪静态
webeidolon 2010-06-30
  • 打赏
  • 举报
回复
是伪静态 我那的空间供应商说他们有自定义ISAPI筛选器功能,能urlrewrite,但我不知道怎么用。
webeidolon 2010-06-29
  • 打赏
  • 举报
回复
大家说得挺好的,但我是个初学者,#12楼说得很详细,但我不知道怎么应用!
Dleno 2010-06-29
  • 打赏
  • 举报
回复
伪静态=>
IIS:
下载ISAPI_REWRITE3的破解版,不然要给钱的.
安装好后直接操作软件就可以进行REWRITE配置

APACHE:

httpd.conf加上:

LoadModule rewrite_module modules/mod_rewrite.so
//这个是apache自带的urlrewrite模块.

站点配置里(例如):
<VirtualHost 192.168.1.101:8888>
DocumentRoot "E:\wwwroot"
Options Indexes
DirectoryIndex index.php
<Directory "E:\wwwroot">
Order allow,deny
Allow from all
</Directory>
#下面就是规则.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)/htm/(.*)$ $1.php?$2
RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
RewriteRule ^(.*)-tmp-(.*)$ $1.php?$2
</IfModule>
</VirtualHost>

页面上的动态地址静态化:
你可以采取最苯的办法,就是自己写成你要地址,然后在rewrite里写配置规则

但通常都是用ob_start()的方式.
即页面最前端:

ob_start();

页面结尾:
$output = ob_get_contents();
//下面就通过程序来处理$output里的页面地址了($output也就是你页面的输出字符),这样更方便你管理
webeidolon 2010-06-29
  • 打赏
  • 举报
回复
求解?
jlzan1314 2010-06-25
  • 打赏
  • 举报
回复
tabris17
现在搜索引擎,对目录的深度有点关系.
后缀好像不分了
jianglin28290 2010-06-25
  • 打赏
  • 举报
回复
.htaccess
tabris17 2010-06-25
  • 打赏
  • 举报
回复
引用
这样的网址不利于与搜索引擎抓取


这种说法已经过时了,现在的搜索引擎对动态网页支持很好,没必要可以静态化。


引用
请教大家如何让带有问号的URL静态化


连配置环境都不讲,不知道怎么想的,看你的口气像是用的IIS,有个叫ISAPI_Rewrite的软件可以支持url rewrite
YHL27 2010-06-25
  • 打赏
  • 举报
回复
learning....
c461439564 2010-06-25
  • 打赏
  • 举报
回复
1 apache(需要配制)
如:.htaccess中
##### NOTE: Replace /shop/ with the relative web path of your catalog in the "Rewrite Base" line below:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /svn/Physical-site/www.raybansunglassesale.com/

# From Ultimate SEO URLs
RewriteRule ^(.*)-p-(.*).html$ index\.php?main_page=product_info&products_id=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-sunglasses-(.*).html$ index\.php?main_page=index&cPath=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-m-([0-9]+).html$ index\.php?main_page=index&manufacturers_id=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-pi-([0-9]+).html$ index\.php?main_page=popup_image&pID=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-pr-([0-9]+).html$ index\.php?main_page=product_reviews&products_id=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-pri-([0-9]+).html$ index\.php?main_page=product_reviews_info&products_id=$2&%{QUERY_STRING} [L]

# For Open Operations Info Manager
RewriteRule ^(.*)-i-([0-9]+).html$ index\.php?main_page=info_manager&pages_id=$2&%{QUERY_STRING} [L]

# For dreamscape's News & Articles Manager
RewriteRule ^news/?$ index\.php?main_page=news&%{QUERY_STRING} [L]
RewriteRule ^news/rss.xml$ index\.php?main_page=news_rss&%{QUERY_STRING} [L]
RewriteRule ^news/archive/?$ index\.php?main_page=news_archive&%{QUERY_STRING} [L]
RewriteRule ^news/([0-9]{4})-([0-9]{2})-([0-9]{2}).html$ index\.php?main_page=news&date=$1-$2-$3&%{QUERY_STRING} [L]
RewriteRule ^news/archive/([0-9]{4})-([0-9]{2}).html$ index\.php?main_page=news_archive&date=$1-$2&%{QUERY_STRING} [L]
RewriteRule ^news/(.*)-a-([0-9]+)-comments.html$ index\.php?main_page=news_comments&article_id=$2&%{QUERY_STRING} [L]
RewriteRule ^news/(.*)-a-([0-9]+).html$ index\.php?main_page=news_article&article_id=$2&%{QUERY_STRING} [L]

# All other pages
# Don't rewrite real files or directories
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*).html$ index\.php?main_page=$1&%{QUERY_STRING} [L]

####### To prohibit the implementation of malicious files directory
RewriteRule ^images/(.*).php$ http://9.0.0.0/images [L]
RewriteRule ^images/(.*).php3$ http://9.0.0.0/images [L]
RewriteRule ^images/(.*).html$ http://9.0.0.0/images [L]
RewriteRule ^images/(.*).htm$ http://9.0.0.0/images [L]
RewriteRule ^download/(.*).php$ http://9.0.0.0/download [L]
RewriteRule ^download/(.*).php3$ http://9.0.0.0/download [L]
RewriteRule ^download/(.*).html$ http://9.0.0.0/download [L]
RewriteRule ^download/(.*).htm$ http://9.0.0.0/download [L]
RewriteRule ^admin/images/(.*).php$ http://9.0.0.0/images [L]
RewriteRule ^admin/images/(.*).php3$ http://9.0.0.0/images [L]
RewriteRule ^admin/images/(.*).html$ http://9.0.0.0/images [L]
RewriteRule ^admin/images/(.*).htm$ http://9.0.0.0/images [L]
####### To prohibit the implementation of malicious files directory





2 程序伪静态

如:
<?php
/******************************
描 述 :完成将普通地址转化为伪静态地址
使用参考:
$url="http://www.zhongya.cn/company/companyshow.php?action=list&page=2";
$urlStr=MakeUrlHtml($url);
echo $urlStr;
*****************************/
function MakeUrlHtml($url)
{
$durl=parse_url($url);
$urlStr="";
if($durl['host']) $urlStr.=$durl['scheme']."://".$durl['host'];
if($durl['path']) $urlStr.=$durl['path'];
if($durl["query"]){
$durl=explode("&",$durl["query"]);
foreach($durl as $surl)
{
$gurl=explode("=",$surl);
$eurl[]=$gurl[0]."-".$gurl[1];
}
$tmpurl=join("/",$eurl).".htm";
$urlStr.="/".$tmpurl;
}
return $urlStr;
}
$url="http://localhost/test/wjt/wjt.php?main_page=product_info&cPath=14_36&products_id=38&action=add_product&shoppingCustomize=1";
$urlStr=MakeUrlHtml($url);
echo "<a href=".$urlStr.">wjt</a>";
?>
tanzhoujavaeelover 2010-06-22
  • 打赏
  • 举报
回复
配置好Apache前端 参数组合成字符串 搜索引擎不在乎你用的是伪静态还是真静态
edapex 2010-06-19
  • 打赏
  • 举报
回复
你用隐藏域的方式用post传,这样很方便,用文件太慢了
Flow_Cloud 2010-06-19
  • 打赏
  • 举报
回复
地址解析?上面说的貌似是伪静态
sylar066 2010-06-19
  • 打赏
  • 举报
回复
伪静态 配置好Apache前端 参数组合成字符串 搜索引擎不在乎你用的是伪静态还是真静态 能找到就OK了
Abin-2008 2010-06-19
  • 打赏
  • 举报
回复
伪静态吧...
PIGer920 2010-06-18
  • 打赏
  • 举报
回复
觉得这种说法有误解,确切的来说是将所谓的静态url对应到动态的url上去。
amani11 2010-06-18
  • 打赏
  • 举报
回复
讨论这种很多,,,http://topic.csdn.net/u/20100618/17/497740ed-2db2-4a85-a382-ff1d6feec81e.html
你指的是rewrite,apache的,

还有就是真正静态化,生成静态文件,

都有利有弊,权衡选择

4,250

社区成员

发帖
与我相关
我的任务
社区描述
国内外优秀PHP框架讨论学习
社区管理员
  • Framework
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧