phpstudy怎么配置伪静态

2025-04-15 09:02:23
推荐回答(2个)
回答1:

打开phpstudy的配置文件。 httpd.conf
在phpStudy\Apache2\conf文件夹里。用记事本就可以了。
或者,你在任务栏点击phpstudy程序图标,选 配置文件,选 httpd.conf
都可以。

然后
搜索 LoadModule rewrite_module modules/mod_rewrite.so
去掉前面的#
搜索AllowOverride None 替换为 AllowOverride All
有好几个找到和下面代码类似的那个

#
# "D:\usr\local\Apache2\cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#

AllowOverride All
Options None
Order allow,deny
Allow from all


改好以后,接着在最后一行添加: (这个是关键点)


RewriteEngine On

RewriteCond %{QUERY_STRING} ^(.*)$

RewriteRule ^(.*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2&%1

RewriteCond %{QUERY_STRING} ^(.*)$

RewriteRule ^(.*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3&%1

RewriteCond %{QUERY_STRING} ^(.*)$

RewriteRule ^(.*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3&%1

RewriteCond %{QUERY_STRING} ^(.*)$

RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page\%3D$4&page=$3&%1

RewriteCond %{QUERY_STRING} ^(.*)$

RewriteRule ^(.*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3&%1

RewriteCond %{QUERY_STRING} ^(.*)$

RewriteRule ^(.*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3&%1

RewriteCond %{QUERY_STRING} ^(.*)$

RewriteRule ^(.*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3&%1

RewriteCond %{QUERY_STRING} ^(.*)$

RewriteRule ^(.*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=$3&%1

RewriteCond %{QUERY_STRING} ^(.*)$

RewriteRule ^(.*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3&%1

回答2:

wordpress网站设定伪静态有益于seo优化,而且有益于百度搜索引擎网络爬虫浏览,提升网址文章内容百度收录的速率。下边我共享一下wordpress网站伪静态设定的方式。