Hi,
I decided to share my current 'rewrites' settings for others to benefit from, hopefully, it works for me.
Thanks to dev101 his remark about creating a 301 redirect using rewrite I just had to look for a solution that would comply to SEO guidelines as well as keep Osclass working OK on my VPS from either an url with or without www.
Now if you install Osclass and in config.php you define your website with the url: "
www.mywebsite.com" it means that this is in all cases within Osclass system the "base url". So in the case you would enter your website using mywebsite.com without the www this would cause a 302 redirect if you do not have a 301 redirect rewrite rule and this is not good for SEO.
With the current rewrites suggested by Osclass when using 'pretty' urls (setting in Admin called permalinks) this will make sure the permalinks work ok but you still have to create a 301 redirect if it is not already there.
My rewrites are targeted towards an Osclass config which refers to WEB_PATH = '
www.mywebsite.com' meaning I need a rewrite for my url without www in either my htaccess or in my Apache's VirtualHost that is serving "mywebsite.com". Because I have disabled the htaccess on my VPS for performance reasons I put my rewrites directly in my Apache's VirtualHost but could also be in .htaccess file.
The following rewrite rules work for me and result in the following:
1) website entered using www in url => 200 Response header
2) website entered without www in url => 301 Response header (= permanent redirect and accepted by Google indexing)
3) permalinks either disabled or enabled in Osclass are working
4) prevents abuse of the "send friend" functionality which was mentioned in the forums
RewriteEngine On
RewriteBase /
# Osclass Original rewrites for use with 'pretty' url's
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# Create a 301 permanent redirect to www for SEO sake + in sync with Osclass config WEB_PATH
# Source: https://www.digitalocean.com/community/tutorials/how-to-redirect-www-to-non-www-with-apache-on-centos-7
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
################################
# Block 'sent friend url abuse'
# Forum: http://forums.osclass.org/3-3-x/disable-send-to-a-friend/msg88710/$
################################
RewriteCond %{REQUEST_URI} ^/item/send-friend(.*)$ [NC]
RewriteRule ^.*$ - [F,L]
Regards,
Eric