1

我嘗試了不同的重定向從一個頁面到另一個頁面(頁面移動到另一個url),但沒有什麼是真的工作 - 我一直在404頁面。重定向單頁到另一個頁面 - .htaccess

我想移動到http://www.staskka.com/mladinska-postelja-gasilec.htmlhttp://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的,因爲我把它們放在了類別中,很多這些網站在谷歌上排名很好 - 請問有人能幫我一下嗎?

您的幫助非常感謝..謝謝。

哦,我用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] 
+0

你能在你的問題中發佈完整的.htaccess嗎? – anubhava

+0

如果您使用Opencart,則自定義重定向規則需要在所有其他重定向規則之後的底部添加,否則您可能會收到這些特定錯誤。所以發佈完整的重定向塊可以幫助整理出來。 –

+0

是的,當然..我不能在評論中添加代碼..我將在下面的問題中添加它 – ideep13

回答

0

從我的代碼中發現的問題就在這裏:

rewriterule ^([^?]*) index.php?_route_=$1 [L,QSA] 

由於具有A L標誌,這意味着網址調用之後服務器處理它並在那裏結束,這意味着無論你在這之後寫入的URL是否在上面的條件中被捕獲,都將停止在那裏。

因此,在特定情況下,你需要添加(通知thesame不含L標誌,因爲你需要Opencart的事後處理它):該線後

RewriteRule ^mladinska-postelja-gasilec\.html$ /pohistvo/otroske-posteljice/mladinska-otroška-postelja-gasilec/? [R=301,NC] 

RewriteCond %{HTTP_USER_AGENT} libwww-perl.* 
RewriteRule .* – [F,L] 

讓我澄清我不確定您使用的代碼是否與您希望的行爲相符。但是,這個立場是正確的。另外,因爲在我的評論中,我表示你需要在最後添加這些規則,這主要是爲了處理外部域,對於你的情況(內部URL處理)這是實現它的方式。

+0

謝謝喬尼德。它有一點幫助,但正如你所說的,不是正確的位置。它將我重定向到該類別,但瀏覽器中的uRL不會更改 - 它保持不變 - http://www.staskka.com/mladinska-postelja-gasilec.html – ideep13

+0

hmm使用L標誌來嘗試它:標記:重寫規則^ mladinska -postelja-gasilec \ .html $/pohistvo/otroske-posteljice/mladinska-otroška-postelja-gasilec /? [L,R = 301,NC],再次考慮L標誌是必需的,因爲你現在看到的行爲表明重定向在服務器上,但是由於進一步處理被允許,服務器可以識別它。嘗試與L旗像喲以前有過,並告訴我結果。 –

+0

@ ideep13請查看我的評論並告訴我結果。 –

相關問題