2012-03-06 31 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需要重定向 希望这将有助于完成!