fxgreen
fxgreen

Reputation: 422

Redirect Prestashop 1.5 from subfolder to the root

I have Prestashop 1.5.x installed in subfolder, not in the root. I want it be accesible from root directory, so I edited .htaccess file to set RewriteCond and RewriteRule to change main domain and subfolder. It works, instantly redirects from the main domain to the store.

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

My question: is this correct way, or better redirect using index.html with javascript like this:

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

My concerns is about how to make Prestashop pages SEO-friendly, so store be searchable when installed in subfolder. Or better to move the store from subfolder to the root?

Upvotes: 0

Views: 3113

Answers (1)

Strategio
Strategio

Reputation: 438

Rewritting is different form redirecting.

The .htaccess way is better than a javascript redirect. You save your client a useless request.

Upvotes: 1

Related Questions