将Prestashop 1.5从子文件夹重定向到根目录

时间:2013-05-14 11:30:34

标签: php apache seo prestashop

我在子文件夹中安装了Prestashop 1.5.x,而不是在root中。我希望它可以从根目录访问,所以我编辑.htaccess文件来设置RewriteCond和RewriteRule来更改主域和子文件夹。它可以工作,立即从主域重定向到商店。

# 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]

我的问题:这是正确的方式,还是更好地使用index.html使用这样的javascript重定向:

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

我关注的是如何使Prestashop页面 SEO-friendly ,因此存储在子文件夹中安装时可以搜索。或者更好地将商店从子文件夹移动到根目录?

1 个答案:

答案 0 :(得分:1)

重写重定向不同。

.htaccess 方式优于javascript重定向。您为客户端保存了无用的请求。