This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

emzero439
emzero439

I noticed October uses the following .htaccess

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

    RewriteEngine On

    #Redirect to www
    #RewriteBase /
    #RewriteCond %{HTTP_HOST} ^site.com$
    #RewriteRule ^(.*)$ http://www.site.com/$1 [R=301]]

    ##
    ## You may need to uncomment the following line for some hosting environments,
    ## if you have installed to a subdirectory, enter the name here also.
    ##
    # RewriteBase /

    ##
    ## Black list protected files
    ##
    RewriteRule themes/.*/(layouts|pages|partials)/.*.htm index.php [L,NC]
    RewriteRule uploads/protected/.* index.php [L,NC]

    ##
    ## White listed folders and files
    ##
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteCond %{REQUEST_URI} !\.js
    RewriteCond %{REQUEST_URI} !\.ico
    RewriteCond %{REQUEST_URI} !\.jpg
    RewriteCond %{REQUEST_URI} !\.gif
    RewriteCond %{REQUEST_URI} !\.css
    RewriteCond %{REQUEST_URI} !\.less
    RewriteCond %{REQUEST_URI} !\.scss
    RewriteCond %{REQUEST_URI} !\.png
    RewriteCond %{REQUEST_URI} !\.swf
    RewriteCond %{REQUEST_URI} !\.txt
    RewriteCond %{REQUEST_URI} !\.xml
    RewriteCond %{REQUEST_URI} !\.xls
    RewriteCond %{REQUEST_URI} !\.eot
    RewriteCond %{REQUEST_URI} !\.woff
    RewriteCond %{REQUEST_URI} !\.ttf
    RewriteCond %{REQUEST_URI} !\.svg
    RewriteCond %{REQUEST_URI} !docs/.*
    RewriteCond %{REQUEST_URI} !themes/.*
    RewriteRule ^ index.php [L,NC]

    ##
    ## Standard routes
    ##
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

</IfModule>

When trying to use the known rewrite rule to redirect non-www to www:

Redirect to www

RewriteBase /
RewriteCond %{HTTP_HOST} ^mysite.com$
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301]]

It doesn't work.

I'm no mod_rewrite expert so any detailed guidance will be appreciated.

Thanks

Last updated

emzero439
emzero439

I'm driving my head crazy trying to do this

eeinblack377
eeinblack377

I know its a silly question but did you restart apache after you made the change? Everything looks ok

emzero439
emzero439

I used boilerplate Rewrite rules before any October rules and got it working.

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
fredericomarinho16918
fredericomarinho16918

Thanks emzero! It worked like a charm. Somebody could create a simple plugin to do it?! :)

1-5 of 5

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.