【问题标题】:Redirect Prestashop 1.5 from subfolder to the root将 Prestashop 1.5 从子文件夹重定向到根目录
【发布时间】:2013-05-14 11:30:34
【问题描述】:

我在子文件夹中安装了 Prestashop 1.5.x,而不是在根目录中。我希望它可以从根目录访问,所以我编辑了 .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 友好,以便商店在安装在子文件夹中时可以搜索。还是将商店从子文件夹移动到根目录更好?

【问题讨论】:

    标签: php apache seo prestashop


    【解决方案1】:

    重写不同于重定向

    .htaccess 方式比 javascript 重定向更好。您为您的客户节省了一个无用的请求。

    【讨论】:

    • 使用 .htaccess 文件重写对 SEO 友好吗?与将存储移动到根目录进行比较。
    • 如果您将商店移动到根文件夹,您的网址会更短。根据 SEO 实践,这会更好,因为这会增加 url 中关键字的密度:http://mysite.tld/blue-suede-shoes 会比 http://mysite.tld/prestashop/blue-suede-shoes 更好
    猜你喜欢
    • 1970-01-01
    • 2012-10-23
    • 2017-01-29
    • 2021-09-03
    • 2011-01-19
    • 2011-01-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多