Match domain with or without www

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
thestranger
Posts: 16
Joined: 06 Jun 2024, 04:34

Match domain with or without www

Post by thestranger » 22 Jul 2024, 10:59

Aimeos 2024.07
Laravel 11
PHP 8.2

Hello, is there a setting or a way to map a domain to be the same with or without www? right now aimeos treats www.domain.com and domain.com as being two different domains and I would like to treat it as the same domain. I'm not sure where to look into changing that as in if there's a config setting I might have missed or do I need to look into a specific file?

User avatar
aimeos
Administrator
Posts: 8619
Joined: 01 Jan 1970, 00:00

Re: Match domain with or without www

Post by aimeos » 22 Jul 2024, 11:01

No, there's no such setting. The solution is to add a redirect in your web server from www.domain.com to domain.com
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

thestranger
Posts: 16
Joined: 06 Jun 2024, 04:34

Re: Match domain with or without www

Post by thestranger » 22 Jul 2024, 11:08

Thank you

thestranger
Posts: 16
Joined: 06 Jun 2024, 04:34

Re: Match domain with or without www

Post by thestranger » 22 Jul 2024, 12:00

In case anyone else needs this, here's the .htaccess for this:

Code: Select all

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [L,R=301]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

Post Reply