PrestaShop: non-www URLs redirecting to 404 error page - redirect

I am experiencing a weird issue on my PrestaShop website.
When I am opening an URL without WWW on it, it redirects to the WWW page, but displays 404 page.
for example, when I am trying to access http://mydomain.com/home/contact-us it takes me to http://www.mydomain.com/home/contact-us?controller=404. It should not add ?controller=404 to the end of the url. Why it's doing this and how to fix this issue?

You need to manually edit the .htaccess file of your Prestashop website. You can redirect all non-www urls to add www using this code.
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
Place the code on top of your .htaccess file or within the condition block for checking mod_rewrite

you can set your url under "Preferences > SEO & URLs". you have to change the options "Shop domain" and "SSL domain" there you can set with or without "WWW".

This is most probably cased by not-generated .htaccess file. Go to BackOffice -> Preferences -> SEO & URLs and click [Save]. This will regenerate your .htaccess file.

Related

301 redirect htaccess and Nginx settings issues and .composer folder

I've had some hit and miss results setting up htaccess to forward on a couple of aged domains I acquired to my main site. I wouldn't describe myself as advanced more an enthusiastic intermediate so a nudge in the right direction would be greatly appreciated. I've checked answers but nothing definitive that I can see that relates to my specific issue and the composer folder. In Apache/Nginx I have in directives (http/https)
RewriteEngine On
ErrorDocument 404 https://my-main-site.com/my-page-or-blog-post/
I have 'Restrict the ability to follow symbolic links' unchecked as I have reference to symlinks in htaccess and so avoids a 500 error. I also have put up a static html page so if anyone hits the old aged domain it's not an automatic redirect they'll see the static HTML page with reference to the old/aged domain. So the 301 is sort of in the background but I'm getting a 302 result. My htaccess looks like this......
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^old-site-aged-domain.com$ [NC]
RewriteRule ^(.*)$ https://my-main-site.com/my-page-or-blog-post/ [R=301,L]
However when I go in to AHREFS and look at the backlink data it's showing a 302, however it does confirm http>https is working fine.
http://www.old-site-aged-domain.com/info-page.html
301
https://www.old-site-aged-domain.com/info-page.html
302
https://my-main-site.com/my-page-or-blog-post/
In my site root I also have .composer folder (as well as error_docs, .ssh, httpdocs, logs, .revisium_antivirus_cache), I'm sort of aware what the purpose of this is (PHP) but there are 2 further htaccess files in there, the second smaller htaccess file only has 'deny from all' as content. I wonder if this folder with these 2 htaccess files is presenting a problem/conflict i.e. 3 x htaccess files. The smaller htaccess file is in .composer/cache. The larger htaccess file is in .composer. Should I delete these 2 x htaccess files in .composer folder.
Thanks in advance for any help
James
rewrote htaccess on numerous occasions but without success

Typo3 v10 site configuration with a www-subdomain

I created a site configuration in Typo3 10.4.11 for the entry point www.example.com. When browsing to example.com (without www), I get an error message:
Page Not Found The page did not exist or was inaccessible. Reason: No
site configuration found.
I tried to create a static route, which didnĀ“t work. Any other ideas how to redirect to the original page from www.example.com as well as example.com?
If you're running on Apache, I'd suggest to add a redirect to your .htaccess file:
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
Put the snippet near to the line with RewriteEngine On.
If you want to have both domains served by TYPO3, then the EXT: host_variants may be an option.
https://github.com/b13/host_variants

redirect 301 all pages that doesn't exist to a new directory

i had build another website in the directory http://www.example.com/newwebsite/
Now all the old pages that doesn't exist on the website i want to redirect them to http://www.example.com/newwebsite/
I have a lot of pages in google webmaster with 404 error , that i want to resolve it. I understand that a 301 redirect will resolve my problem.
Can you help me with the htaccess to redirect the pages that doesn't exist any more?
thank you
Try this:
RewriteEngine On
RewriteCond !%{REQUEST_URI} ^/newwebsite/
RewriteRule (.*) /newwebsite/$1 [R=301,L]

bbPress Forum - rewrite to wwww.mysite prohibits login

I am using bbPress installation without WordPress integration.
The redirect of the RewriteEngine at the forum site works:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^forum.mysite.com$
RewriteRule (.*)$ http://www.forum.mysite.com/$1 [R=301,L]
The problem is the login into ppPress.
bbPress login does not recognize: http://www.forum.mysite/bb-login.php.
It redirects to: http://forum.mysite.com/bb-login.php.
I tried permalink settings none and name based, same issue.
Does anyone uses redirect in bbPress or how can I eliminate "double" content and redirect permanently to www.?
I redirected from www.forum.mysite.com to forum.mysite.com and achieved to eliminate "double" content.

.htaccess file disappears in filezilla? how to check if file is present or not?

for some weird reason my CMS is logging out if the address bar does not have www before the full website name. for example, when we enter xyz.com, it takes me to the website but then it wont show as logged in and if i type in www.xyz.com it will find the cookie and show me logged in.
What i want to do is, when user types in xyz.com, i want it to directly (transparent to user) go to www.xyz.com. I want to add that www before xyz.com. I tried adding a .htaccess file in the directory where index.php is present and this is code in htaccess file.
DirectoryIndex index.php
Redirect xyz.com www.xyz.com/index.php
The .htaccess file is disappearing when i transfer it over ftp filezilla.
If you are willing to modify your index.php you could add the following logic to the top of the file:
/*This is a tempory redirection from mysite.com to www.mysite.com*/
if($_SERVER['SERVER_NAME'] == 'mysite.com')
{
$redirect = $_SERVER['REQUEST_URI'];
header( 'Location: http://www.mysite.com'. $redirect ) ;
}
try this in the htaccess file:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^xyz.com$
RewriteRule ^/?$ "http://www.xyz.com" [R=301,L]
However, your problem sounds like cookie related. Probably the CMS is using a cookie to check the log in status, but the cookie domain param is 'www.xyz.com' instead of '.xyz.com'.
--- edit ---
improved a bit the final line of the code (it is tested and working), but as tcp said, mod_rewrite must be enabled. If you can't enable it, try the code that Lobsterm posted and if you can't do this either, you could try to change the cookie domain param from 'www.xyz.com' to '.xyz.com'
If you want to use rewrites, make sure mod_rewrite is being loaded in your Apache conf file and check that the AllowOverride parameter is either set to All or the just the directives you want to be allowed in .htaccess
Also as aletzo said, you probably want your cookie to cover your whole domain so change the cookie domain from www.example.com to example.com .
Then, it won't matter if user are accessing with a www prefix or within a subdomain.
EDIT: Glad you found the answer you were looking for, but if you need to make filezilla show you .htaccess in the future, Server -> Force showing hidden files