0

我不是 PHP 开发人员,我被要求执行一些 SEO。这是我的 .htaccess

    RewriteEngine On
    RewriteBase /
    RewriteRule [_\ ] space.cgi [L]
    ErrorDocument 404 /errors/404.php 
    ErrorDocument 400 /errors/badrequest.php
    ErrorDocument 401 /errors/authreqd.php
    ErrorDocument 403 /errors/forbid.php
    ErrorDocument 500 /errors/serverr.php 
    ErrorDocument 503 /errors/ServiceUnavailable.php 

    RewriteEngine On 
    RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR] 
    RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot@yahoo.com [OR] 
    RewriteCond %{HTTP_USER_AGENT} ^ChinaClaw [OR] 
    RewriteCond %{HTTP_USER_AGENT} ^Custo [OR] 
    RewriteCond %{HTTP_USER_AGENT} ^DISCo [OR] 
    RewriteCond %{HTTP_USER_AGENT} ^GetWeb! [OR] 
    RewriteCond %{HTTP_USER_AGENT} ^Go!Zilla [OR] 
    RewriteCond %{HTTP_USER_AGENT} ^Go-Ahead-Got-It [OR] 
    RewriteCond %{HTTP_USER_AGENT} ^GrabNet [OR] 
    RewriteCond %{HTTP_USER_AGENT} ^Grafula [OR] 
    RewriteCond %{HTTP_USER_AGENT} ^HMView [OR] 
    RewriteCond %{HTTP_USER_AGENT} HTTrack [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} ^Image\ Stripper [OR] 
    RewriteCond %{HTTP_USER_AGENT} ^Image\ Sucker [OR] 
    RewriteCond %{HTTP_USER_AGENT} Indy\ Library [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} ^InterGET [OR] 
    RewriteCond %{HTTP_USER_AGENT} ^Internet\ Ninja [OR] 
    RewriteCond %{HTTP_USER_AGENT} ^JetCar [OR] 
    RewriteCond %{HTTP_USER_AGENT} ^JOC\ Web\ Spider [OR] 
    RewriteCond %{HTTP_USER_AGENT} ^larbin [OR] 
    RewriteCond %{HTTP_USER_AGENT} ^LeechFTP [OR] 
    RewriteCond %{HTTP_USER_AGENT} ^Website\ Quester [OR] 
    RewriteCond %{HTTP_USER_AGENT} ^WebStripper [OR] 
    RewriteCond %{HTTP_USER_AGENT} ^WebWhacker [OR] 
    RewriteCond %{HTTP_USER_AGENT} ^WebZIP [OR] 
    RewriteCond %{HTTP_USER_AGENT} ^Wget [OR] 
    RewriteCond %{HTTP_USER_AGENT} ^Widow [OR] 
    RewriteCond %{HTTP_USER_AGENT} ^WWWOFFLE [OR] 
    RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [OR] 
    RewriteCond %{HTTP_USER_AGENT} ^Zeus 
    RewriteRule ^.* - [F,L]
    RewriteRule rss.xml rss.php [QSA,L]

    RewriteEngine on
    RewriteRule ^index.htm$ index.php
    RewriteRule ^search.htm$ search.php
    RewriteRule ^about.htm$ about.php
    RewriteRule ^contacts.htm$ contacts.php
    RewriteRule ^gallery.htm$ gallery.php
    RewriteRule readmore.htm$ readmore.php

    RewriteEngine on

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule .* $0.php

    RewriteEngine on

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.htm -f
    RewriteRule .* $0.htm

我正在尝试重写我的 URL 以对 SEO 更友好,我正在使用以下代码在我的 .htaccess 文件中执行此操作:

RewriteEngine On      
RewriteRule blog/(.*)/$ readmore.php?&postid=$1 [NC]      
RewriteRule ^/*(.+/)?([^.]*[^/])$ http://%{HTTP_HOST}/$1$2/ [L,R=301]

最后一个代码不适用于我的网站:我不知道!请帮助 http://www.afrogfx.com/index

要转换的网址

 http://www.afrogfx.com/readmore?postid=62&categories=6&catid=6#.UG3ZoK5adS8

或者

http://www.afrogfx.com/readmore?postid=62

4

1 回答 1

0

最后一个代码不适用于我的网站:S 我不知道

你不能匹配 a 中的查询字符串RewriteRule,你也不想盲目地重写 URI,因为规则就在它之前,你只会导致重定向循环。将您的第二条规则更改为:

RewriteCond %{THE_REQUEST} ^(GET|POST|HEAD)\ /readmore\.php\?
RewriteCond %{QUERY_STRING} postid=([^&]+)
RewriteRule ^ /blog/%1/ [L,R=301]
于 2012-10-04T19:08:26.293 回答