2012-03-06 96 views
0

我有一個老皮爾商店,我在Prestashop上移動。在切換之前,我想保留Google上的一些產品(大約100個產品)。htaccess從不存在的文件永久重定向

到目前爲止,我在Prestashop pre-prod服務器上做了測試,其域名如「mywebsite.com/~subfolder/」(託管公司強制)。所有產品都從皮爾進口到Prestashop。

我認爲,一個簡單的

Options +FollowSymlinks  
RewriteEngine on 
RedirectPermanent /~subfolder/achat/product_detail.php?id=300 http://www.mywebsite.com/~subfolder/my/new/url-300.html 

會的工作,但我總是重定向到的Prestashop找不到網頁。據我所知,它不接受「achat/product_detail.php」不存在的事實。

我也試過

RewriteRule ^/~subfolder/achat/produit_details.php?id=110$ /~subfolder/layette-en-laine-et-soie/110-brassiere-laine-et-soie.html [L,R=301] 

這是行不通的更好。

處理這個問題的正確方法是什麼?如果可能,以相對的方式表示當我切換Prestashop直播(並將http://mywebsite.com/~subfolder更改爲http://www.mywebsite.com)時,我不希望修改該文件。

任何幫助將不勝感激!

感謝,

薩科

PS:如果需要的話,下面的的Prestashop生成我的htaccess文件(我刪除上述mentionned測試):

# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution 
# WARNING: PLEASE DO NOT MODIFY THIS FILE MANUALLY. IF NECESSARY, ADD YOUR SPECIFIC CONFIGURATION WITH THE HTACCESS GENERATOR IN BACK OFFICE 
# http://www.prestashop.com - http://www.prestashop.com/forums 

SetEnv PHP_VER 5_TEST 
SetEnv REGISTER_GLOBALS 0 

AuthUserFile /XXXX 
AuthGroupFile /dev/null 
AuthName "Veuillez vous identifier" 
AuthType Basic 


require valid-user 

<IfModule mod_rewrite.c> 

# URL rewriting module activation 
RewriteEngine on 

# URL rewriting rules 
RewriteRule ^api/?(.*)$ /~subfolder/webservice/dispatcher.php?url=$1 [QSA,L] 
RewriteRule ^([a-z0-9]+)\-([a-z0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$ /~subfolder/img/p/$1-$2$3.jpg [L] 
RewriteRule ^([0-9]+)\-([0-9]+)/[_a-zA-Z0-9-]*\.jpg$ /~subfolder/img/p/$1-$2.jpg [L] 
RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /~subfolder/img/p/$1/$1$2.jpg [L] 
RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /~subfolder/img/p/$1/$2/$1$2$3.jpg [L] 
RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /~subfolder/img/p/$1/$2/$3/$1$2$3$4.jpg [L] 
RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /~subfolder/img/p/$1/$2/$3/$4/$1$2$3$4$5.jpg [L] 
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /~subfolder/img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg [L] 
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /~subfolder/img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg [L] 
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /~subfolder/img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8.jpg [L] 
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /~subfolder/img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg [L] 
RewriteRule ^c/([0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$ /~subfolder/img/c/$1$2.jpg [L] 
RewriteRule ^c/([a-zA-Z-]+)/[a-zA-Z0-9-]+\.jpg$ /~subfolder/img/c/$1.jpg [L] 
RewriteRule ^([0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$ /~subfolder/img/c/$1$2.jpg [L] 
RewriteRule ^([0-9]+)\-[a-zA-Z0-9-]*\.html /~subfolder/product.php?id_product=$1 [QSA,L] 
RewriteRule ^[a-zA-Z0-9-]*/([0-9]+)\-[a-zA-Z0-9-]*\.html /~subfolder/product.php?id_product=$1 [QSA,L] 
RewriteRule ^([0-9]+)\-[a-zA-Z0-9-]*(/[a-zA-Z0-9-]*)+ /~subfolder/category.php?id_category=$1&noredirect=1 [QSA,L] 
RewriteRule ^([0-9]+)\-[a-zA-Z0-9-]* /~subfolder/category.php?id_category=$1 [QSA,L] 
RewriteRule ^([0-9]+)__([a-zA-Z0-9-]*) /~subfolder/supplier.php?id_supplier=$1 [QSA,L] 
RewriteRule ^([0-9]+)_([a-zA-Z0-9-]*) /~subfolder/manufacturer.php?id_manufacturer=$1 [QSA,L] 
RewriteRule ^content/([0-9]+)\-([a-zA-Z0-9-]*) /~subfolder/cms.php?id_cms=$1 [QSA,L] 
RewriteRule ^content/category/([0-9]+)\-([a-zA-Z0-9-]*) /~subfolder/cms.php?id_cms_category=$1 [QSA,L] 
RewriteRule ^page-non-trouvee$ /~subfolder/404.php [QSA,L] 
RewriteRule ^adresse$ /~subfolder/address.php [QSA,L] 
RewriteRule ^adresses$ /~subfolder/addresses.php [QSA,L] 
RewriteRule ^authentification$ /~subfolder/authentication.php [QSA,L] 
RewriteRule ^meilleures-ventes$ /~subfolder/best-sales.php [QSA,L] 
RewriteRule ^panier$ /~subfolder/cart.php [QSA,L] 
RewriteRule ^contactez-nous$ /~subfolder/contact-form.php [QSA,L] 
RewriteRule ^bons-de-reduction$ /~subfolder/discount.php [QSA,L] 
RewriteRule ^suivi-commande-invite$ /~subfolder/guest-tracking.php [QSA,L] 
RewriteRule ^historique-des-commandes$ /~subfolder/history.php [QSA,L] 
RewriteRule ^identite$ /~subfolder/identity.php [QSA,L] 
RewriteRule ^fabricants$ /~subfolder/manufacturer.php [QSA,L] 
RewriteRule ^mon-compte$ /~subfolder/my-account.php [QSA,L] 
RewriteRule ^nouveaux-produits$ /~subfolder/new-products.php [QSA,L] 
RewriteRule ^commande$ /~subfolder/order.php [QSA,L] 
RewriteRule ^details-de-la-commande$ /~subfolder/order-follow.php [QSA,L] 
RewriteRule ^commande-rapide$ /~subfolder/order-opc.php [QSA,L] 
RewriteRule ^avoirs$ /~subfolder/order-slip.php [QSA,L] 
RewriteRule ^mot-de-passe-oublie$ /~subfolder/password.php [QSA,L] 
RewriteRule ^promotions$ /~subfolder/prices-drop.php [QSA,L] 
RewriteRule ^recherche$ /~subfolder/search.php [QSA,L] 
RewriteRule ^plan-du-site$ /~subfolder/sitemap.php [QSA,L] 
RewriteRule ^magasins$ /~subfolder/stores.php [QSA,L] 
RewriteRule ^fournisseurs$ /~subfolder/supplier.php [QSA,L] 
</IfModule> 

# Catch 404 errors 
ErrorDocument 404 /~subfolder/404.php 

<IfModule mod_expires.c> 
    ExpiresActive On 
    ExpiresByType image/gif "access plus 1 month" 
    ExpiresByType image/jpeg "access plus 1 month" 
    ExpiresByType image/png "access plus 1 month" 
    ExpiresByType text/css "access plus 1 week" 
    ExpiresByType text/javascript "access plus 1 week" 
    ExpiresByType application/javascript "access plus 1 week" 
    ExpiresByType application/x-javascript "access plus 1 week" 
    ExpiresByType image/x-icon "access plus 1 year" 
</IfModule> 

FileETag INode MTime Size 
<IfModule mod_deflate.c> 
    AddOutputFilterByType DEFLATE text/html 
    AddOutputFilterByType DEFLATE text/css 
    AddOutputFilterByType DEFLATE text/javascript 
    AddOutputFilterByType DEFLATE application/javascript 
    AddOutputFilterByType DEFLATE application/x-javascript 
</IfModule> 

回答

0

不能匹配對查詢字符串使用RewriteRule,並且不能在Redirect指令中包含查詢字符串。您需要使用一個RewriteCond的查詢字符串:

RewriteCond %{QUERY_STRING} ^id=110$ 
RewriteRule ^~subfolder/achat/produit_details.php$ /~subfolder/layette-en-laine-et-soie/110-brassiere-laine-et-soie.html [L,R=301] 

請注意,您還需要刪除的領先/在比賽中,因爲它被通過重寫引擎的.htaccess文件中剝離。

+0

你好,非常感謝你的回答。不幸的是,它不工作...仍然有一個未找到的頁面。關於附帶的htaccess文件,它有一個特定的地方,我應該把你的線?你知道爲什麼它不起作用嗎?謝謝 ! – 2012-03-07 07:16:06

+0

@NicolasBONNIOT你需要把規則放在現有的'RewriteRule'之前。 – Gerben 2012-03-07 16:01:58

0

我終於回答我的問題:萬一上面的相關詳細的解決方案有一個有效的重定向低於:

RewriteCond %{QUERY_STRING} ^id=110$ 
RewriteRule ^achat/produit_details.php$ /~subfolder/layette-en-laine-et-soie/110-brassiere-laine-et-soie.html [L,R=301] 

各產品的ID需要重定向 希望這將有助於完成!