Hello,嗨,大家好,我是哈喽猿。
这里是哈喽猿网
今天推送的是wordpress教程的文章,感谢您宝贵的时间阅读
WordPress新手入门课程目录:
10.WordPress伪静态
前言:伪静态最重要的是,为了方便搜索引擎蜘蛛(Spider)掌握网页上的相关内容,提高用户对网页的信任,使我们的网站能够在搜索引擎中有一个良好的排名,下面哈喽猿来教大家WordPress 如何使用伪静态
Nginx伪静态规则
nginx环境通常由VPS或Linux主机的服务器用户使用。这些用户通常自己配置nginx,或者有一个特殊的人来帮助您配置和打开它nginx.conf格式或站点的配置环境,例如wpdaxue.com.conf网站(与人工配置不同),在服务器{}大括号中添加以下代码,保存,重启 Nginx 即可。
location <span style="color: #339933;">/</span> <span style="color: #009900;">{</span>
try_files <span style="color: #000088;">$uri</span> <span style="color: #000088;">$uri</span><span style="color: #339933;">/</span> <span style="color: #339933;">/</span>index<span style="color: #339933;">.</span>php?<span style="color: #000088;">$args</span><span style="color: #339933;">;</span>
<span style="color: #009900;">}</span>
<span style="color: #666666; font-style: italic;"># Add trailing slash to */wp-admin requests.
</span>rewrite <span style="color: #339933;">/</span>wp<span style="color: #339933;">-</span>admi
Apache伪静态规则
Apache是Linux主机下的一个常见环境,现在在普通Linux虚拟主机中使用。创建一个新的htaccess.txt文件,添加以下代码并将其上传到WordPress站点的根目录,将其重命名为.htaccess
<span style="color: #339933;"><</span>IfModule mod_rewrite<span style="color: #339933;">.</span>c<span style="color: #339933;">></span>
RewriteEngine On
RewriteBase <span style="color: #339933;">/</span>
RewriteRule ^index\<span style="color: #339933;">.</span>php$ <span style="color: #339933;">-</span> <span style="color: #009900;">[</span>L<span style="color: #009900;">]</span>
RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">{</span>REQUEST_FILENAME<span style="color: #009900;">}</span> <span style="color: #339933;">!-</span>f
RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">{</span>REQUEST_FILENAME<span style="color: #009900;">}</span> <span style="color: #339933;">!-</span>d
RewriteRule <span style="color: #339933;">.</span> <span style="color: #339933;">/</span>index<span style="color: #339933;">.</span>php <span style="color: #009900;">[</span>L<span style="color: #009900;">]</span>
<span style="color: #339933;"></</span>IfModule<span style="color: #339933;">></span>
IIS伪静态规则
IIS环境是windows主机的通用服务器环境。创建一个新的TXT文件,将以下代码添加到该文件中,并将其另存为httpd.ini公司文件,上传到WordPress站点的根目录。
<span style="color: #009900;">[</span>ISAPI_Rewrite<span style="color: #009900;">]</span>
<span style="color: #666666; font-style: italic;"># Defend your computer from some worm attacks
</span><span style="color: #666666; font-style: italic;">#RewriteRule .*(?:global.asa|default\.ida|root\.exe|\.\.).* . [F,I,O]
</span><span style="color: #666666; font-style: italic;"># 3600 = 1 hour
</span>
CacheClockRate <span style="color: #cc66cc;">3600</span>
RepeatLimit <span style="color: #cc66cc;">32</span>
<span style="color: #666666; font-style: italic;"># Protect httpd.ini and httpd.parse.errors files
</span><span style="color: #666666; font-style: italic;"># from accessing through HTTP
</span><span style="color: #666666; font-style: italic;"># Rules to ensure that normal content gets through
</span>
RewriteRule <span style="color: #339933;">/</span>tag<span style="color: #339933;">/</span><span style="color: #009900;">(</span><span style="color: #339933;">.*</span><span style="color: #009900;">)</span> <span style="color: #339933;">/</span>index\<span style="color: #339933;">.</span>php\?tag<span style="color: #339933;">=</span>$<span style="color:#800080;">1</span>
RewriteRule <span style="color: #339933;">/</span>software<span style="color: #339933;">-</span>files<span style="color: #339933;">/</span><span style="color: #009900;">(</span><span style="color: #339933;">.*</span><span style="color: #009900;">)</span> <span style="color: #339933;">/</span>software<span style="color: #339933;">-</span>files<span style="color: #339933;">/</span>$<span style="color:#800080;">1</span> <span style="color: #009900;">[</span>L<span style="color: #009900;">]</span>
RewriteRule <span style="color: #339933;">/</span>images<span style="color: #339933;">/</span><span style="color: #009900;">(</span><span style="color: #339933;">.*</span><span style="color: #009900;">)</span> <span style="color: #339933;">/</span>images<span style="color: #339933;">/</span>$<span style="color:#800080;">1</span> <span style="color: #009900;">[</span>L<span style="color: #009900;">]</span>
RewriteRule <span style="color: #339933;">/</span>sitemap<span style="color: #339933;">.</span>xml <span style="color: #339933;">/</span>sitemap<span style="color: #339933;">.</span>xml <span style="color: #009900;">[</span>L<span style="color: #009900;">]</span>
RewriteRule <span style="color: #339933;">/</span>favicon<span style="color: #339933;">.</span>ico <span style="color: #339933;">/</span>favicon<span style="color: #339933;">.</span>ico <span style="color: #009900;">[</span>L<span style="color: #009900;">]</span>
<span style="color: #666666; font-style: italic;"># For file-based wordpress content (i.e. theme), admin, etc.
</span>RewriteRule <span style="color: #339933;">/</span>wp<span style="color: #339933;">-</span><span style="color: #009900;">(</span><span style="color: #339933;">.*</span><span style="color: #009900;">)</span> <span style="color: #339933;">/</span>wp<span style="color: #339933;">-</span>$<span style="color:#800080;">1</span> <span style="color: #009900;">[</span>L<span style="color: #009900;">]</span>
<span style="color: #666666; font-style: italic;"># For normal wordpress content, via index.php
</span>RewriteRule ^<span style="color: #339933;">/</span>$ <span style="color: #339933;">/</span>index<span style="color: #339933;">.</span>php <span style="color: #009900;">[</span>L<span style="color: #009900;">]</span>
RewriteRule <span style="color: #339933;">/</span><span style="color: #009900;">(</span><span style="color: #339933;">.*</span><span style="color: #009900;">)</span> <span style="color: #339933;">/</span>index<span style="color: #339933;">.</span>php<span style="color: #339933;">/</span>$<span style="color:#800080;">1</span> <span style="color: #009900;">[</span>L<span style="color: #009900;">]</span>
0 评论