【发布时间】:2014-08-10 06:10:48
【问题描述】:
我尝试了从一个页面到另一个页面的不同重定向(页面移动到另一个 url),但没有任何效果 - 我不断收到 404 页面。
我想将http://www.staskka.com/mladinska-postelja-gasilec.html 移动到http://www.staskka.com/otroska-oprema/otroske-posteljice/mladinska-otro%C5%A1ka-postelja-gasilec.html
什么都没有发生。仍然找不到 404 页面。
.htaccess 中的代码是:
# BEGIN Permanent URL redirects
RewriteRule ^mladinska-postelja-gasilec\.html$ /pohistvo/otroske-posteljice/mladinska-otroška-postelja-gasilec/? [L,R=301,NC]
我也有从非 www 重定向到 www.. 并且工作正常..
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
我只需要重定向一些 URL,因为我将它们放在类别中,并且很多此类网站在 google 上的排名都非常好——有人可以帮帮我吗?
非常感谢您的帮助..谢谢。
哦,我使用的是 OC 1.5.1.3。
编辑:这是整个 .htaccess
rewriteengine on
rewritecond %{HTTP_HOST} ^www.djecje-kuhinje.com$ [OR]
rewritecond %{HTTP_HOST} ^djecje-kuhinje.com$
rewriterule ^djecje-kuhinje-com\/ "http\:\/\/shop\.djecje-kucice\.com\/" [R=301,L] #52b5421b82424
rewritecond %{HTTP_HOST} ^www.otroska-kuhinja.si$ [OR]
rewritecond %{HTTP_HOST} ^otroska-kuhinja.si$
rewriterule ^otroska-kuhinja\/ "http\:\/\/www\.otroskekuhinje\.si\/" [R=301,L] #51f13a48f336e
rewritecond %{HTTP_HOST} ^kidkraft.staskka.com$
rewriterule ^kidkraft\/ "http\:\/\/www\.staskka\.com\/" [R=301,L] #50f3d3a25618d
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* – [F,L]
##BEGIN MOBILE (do not edit below this line)
RewriteBase /
##END MOBILE
rewriterule test\.htm http://www.google.com [R]
rewritecond %{HTTP_USER_AGENT} ((.*iPhone.*)|(.*iPod.*)|(.*BlackBerry.*)|(.*Android.*Mobile.*)|(.*Windows\ CE.*)|(.*IEMobile.*)|(.*Opera\ Mini.*)|(.*Opera\ Mobi.*))
rewritecond %{HTTP_COOKIE} !dm_show_classic
rewritecond %{QUERY_STRING} !no_redirect=true [NC]
rewritecond %{HTTP_HOST} ^www\. [NC,OR]
rewritecond %{HTTP_HOST} ^[0-9a-z-]+\.[a-z]+$ [NC]
rewritecond %{REQUEST_URI} ^/_dm/s/ [NC,OR]
rewritecond %{REQUEST_FILENAME} !\.(jpg|gif|png|css|js|txt|ico|pdf|bmp|tif|mp3|wav|wma|asf|mp4|flv|mpg|avi|csv|doc|docx|xls|xlsx|ppt|pptx|zip|rar|tar|gz|dmg|iso)$ [NC]
rewriterule ^(.*)$ http://mobile.staskka.com/ [R,L]
rewriterule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
rewriterule ^googlebase.xml$ index.php?route=feed/google_base [L]
rewriterule ^download/(.*) /index.php?route=error/not_found [L]
rewritecond %{REQUEST_FILENAME} !-f
rewritecond %{REQUEST_FILENAME} !-d
rewritecond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
rewriterule ^([^?]*) index.php?_route_=$1 [L,QSA]
# compress text, HTML, JavaScript, CSS, and XML
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
# remove browser bugs
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 week"
ExpiresByType image/jpeg "access plus 1 week"
ExpiresByType image/gif "access plus 1 week"
ExpiresByType image/png "access plus 1 week"
ExpiresByType text/css "access plus 1 week"
ExpiresByType application/pdf "access plus 1 week"
ExpiresByType text/x-javascript "access plus 1 week"
ExpiresByType application/x-shockwave-flash "access plus 1 week"
ExpiresByType image/x-icon "access plus 1 week"
ExpiresDefault "access plus 1 week"
</IfModule>
## EXPIRES CACHING ##
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
# BEGIN Permanent URL redirects
RewriteRule ^mladinska-postelja-gasilec\.html$ /pohistvo/otroske-posteljice/mladinska-otroška-postelja-gasilec/? [L,R=301,NC]
RewriteCond %{SCRIPT_FILENAME} !-s
RewriteRule (.*) index.php?path=$1 [QSA,L]
【问题讨论】:
-
您可以在问题中发布完整的 .htaccess 吗?
-
如果您使用的是 Opencart,则需要在所有其他重定向规则之后在底部添加自定义重定向规则,否则您可能会收到这些特定错误。所以发布完整的重定向块可以帮助解决这个问题。
-
是的,当然..我无法在评论中添加代码..我将在下面的问题中添加它
标签: .htaccess redirect http-status-code-404 opencart http-status-code-301