我不是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
我正在尝试将我的网址重写为更友好的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
OR
答案 0 :(得分:0)
最后一个代码无法使用我的网站:我不知道
您无法匹配RewriteRule
中的查询字符串,您也不希望盲目地重写URI,因为规则就在它之前,并且您只会导致重定向循环。将您的第二条规则更改为:
RewriteCond %{THE_REQUEST} ^(GET|POST|HEAD)\ /readmore\.php\?
RewriteCond %{QUERY_STRING} postid=([^&]+)
RewriteRule ^ /blog/%1/ [L,R=301]