htaccess removes a bar (/) from the url when using WWW in the Prestashop

Asked

Viewed 284 times

-2

I have a version 1.7.6 multi-store installation enabled.

At first, Prestashop set up htaccess already. Each store is accessed as follows:

turns out that when trying to use www (www.meudominio.com/store-x), htaccess should redirect to correct https?

in the main domain he can do that:

of: - www.meudominio.com

for: - https://meudominio.com

now, when I try to access a store with www, htaccess removes the URL bar. the result is this:

of: - www.meudominio.com/shop-x

for: - https://meudominio.comloja-x

Has anyone ever faced a similar problem? Got any tips on how to fix?

I don’t know how to handle htacces, I’ve tried some things but without success.

follows the excerpt from htacces that I believe is making these changes:

.htaccess

//-------------------------------------------------------------

Rewritecond %{HTTP_HOST} meudominio.com$

Rewriterule . - [E=REWRITEBASE:/]

Rewriterule api(?:/(.*))? $ %{ENV:REWRITEBASE}webservice/Dispatcher.php? url=$1 [QSA,L]

Rewritecond %{HTTP_HOST} meudominio.com$

Rewriterule demo$ /demo/ [L,R]

Rewritecond %{HTTP_HOST} meudominio.com$

Rewriterule demo/(.*) /$1 [L]

//-------------------------------------------------------------

my htaccess has several snippets similar to this, but it is one for each store I have registered.. the Store itself that created these settings.

In the above case, it is a rule for the store called "demo" Just replace my real domain with "mydomain"

  • Already tried: RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^meudominio.com$, see here ...

  • Yes, I had checked that article earlier. But I couldn’t solve it, I also checked on DNS settings thinking it might be the problem. After several attempts I believe it really is something in htaccess

1 answer

0

Try it like this:

//-------------------------------------------------------------

RewriteCond %{HTTP_HOST} ^(www\.)?meudominio\.com$

RewriteRule . - [E=REWRITEBASE:/]

RewriteRule ^api(?:/(.*))?$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]

RewriteCond %{HTTP_HOST} ^(www\.)?meudominio\.com$

RewriteRule ^demo$ /demo/ [L,R]

RewriteCond %{HTTP_HOST} ^(www\.)?meudominio\.com$

RewriteRule ^demo/(.*) /$1 [L]

//-------------------------------------------------------------
  • Ivan, I tried to use the code but the problem remained the same. I restarted apache and cleared the cache of the Prestashop. Is the problem in another snippet of htaccess? There is a snippet that is at the beginning of the file that looks like some more general rules.. follows the excerpt: <Ifmodule mod_rewrite. c> <Ifmodule mod_env. c> Setenv HTTP_MOD_REWRITE On </Ifmodule> Rewriteengine on #Domain: meudominio.com Rewritecond %{HTTP_HOST} meudominio.com$ Rewriterule . - [E=REWRITEBASE:/] Rewriterule api(?:/(.*))? $ %{ENV:REWRITEBASE}webservice/Dispatcher.php? url=$1 [QSA,L]

  • I find it strange that you say . htaccess remove the bar, because, by logic, the . htaccess has a rewrite rule, but in fact it is only an interpreter of how it should receive the value and, it does not remove bars, it just redirects to the way the rewrite was defined in the rule. Understand that it does not create anything, it is based on the input that comes, and sends the output that you mask.

  • You’re telling me when you access a www address in front, it’s removing the bar, I can’t understand, how you’re accessing this address, is it a link on your page? Or when you hit the normal link, it’s rewriting to this no bar?

  • I type in the browser "www.meudominio.com/store-x", then I get a 301 response which is redirect isn’t? only I get redirected to the address "https://meudominio.comloja-x" and then an error, because this address does not exist. if I add the bar to that final address then it works. I thought it was htaccess that "formatted" the new url to which I would be redirected.. but if it’s not him who’s redirecting me to this wrong url, then I don’t know where to look, I’ll look again at the configs on dns

Browser other questions tagged

You are not signed in. Login or sign up in order to post.