2013-05-14 175 views
0

我已將Prestashop 1.5.x安裝在子文件夾中,而不是在根目錄中。我希望它可以從根目錄訪問,所以我編輯.htaccess文件來設置RewriteCond和RewriteRule來更改主域和子文件夾。它可以工作,即時從主域重定向到商店。將Prestashop 1.5從子文件夾重定向到根

# Copy and paste the following code into the .htaccess file 
# in the public_html folder of your hosting account 
# make the changes to the file according to the instructions. 

# Do not change this line - RewriteEngine on 
RewriteEngine on 

# Change yourdomain.com to be your main domain. 
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$ 

# Change 'subfolder' to be the folder you will use for your main domain. 
RewriteCond %{REQUEST_URI} !^/prestashop/ 

# Don't change this line. 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

# Change 'subfolder' to be the folder you will use for your main domain. 
RewriteRule ^(.*)$ /prestashop/$1 

# Change yourdomain.com to be your main domain again. 
# Change 'subfolder' to be the folder you will use for your main domain 
# followed by/then the main file for your site, index.php, index.html, etc. 
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$ 
RewriteRule ^(/)?$ prestashop/index.php [L] 

我的問題:這是正確的方式,或通過JavaScript重定向更好用的index.html像這樣:

<head> 
<script type="text/javascript"><!-- 
location.replace("http://maindomain.com/shop/index.php") 
//--> 
</script> 
    <title></title> 
</head> 

我的擔憂是如何使的Prestashop頁面SEO友好,所以存儲在安裝在子文件夾中時可以搜索。或者更好地將商店從子文件夾移到根目錄?

回答

1

重寫是不同的形式重定向

.htaccess方式比JavaScript重定向更好。你爲你的客戶節省了一個無用的請求。

+0

使用.htaccess文件重寫是否對搜索引擎友好?與將商店移動到根目錄相比較。 – fxgreen 2013-05-14 13:24:08

+0

如果您將商店移到根文件夾,您的網址將會變短。根據搜索引擎優化的做法,這是更好的,因爲這增加了關鍵字的密度在URL:'http:// mysite.tld/blue-suede-shoes'會比'http://mysite.tld/prestashop/blue-麂皮shoes' – Strategio 2013-05-14 13:44:40

相關問題