WordPress htaccess issue with www

I have a WordPress website that is set to direct to www by default. Everything works perfectly, however I have a few sections that are custom coded, to go to “profile” pages of local services, accommodation etc. this works fine in development however on the live server when you access the link via www.example.com/services/example-here/ it redirects to example.com/wp-content/themes/theme-here/custom/services.php?slug=example-here

I’ve been told by my webhost that it is WordPRess that is causing the issue, however everything says www.example.com/ (siteurl etc.)

Read More

Here is the code in the htaccess file:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]

RewriteRule ^.*services/(.*)/$ /wp-content/themes/theme-here/custom/services.php?slug=$1 [QSA,L]
RewriteRule ^.*accommodation/(.*)/$ /wp-content/themes/theme-here/custom/accommodation.php?slug=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Any ideas I’ve checked all my settings, Could it be a host issue inside of apache conf to do with mod re-write? I also might add that the code works perfectly without the www’s added but my client requires the www.

Related posts

Leave a Reply

1 comment

    1. Add a www forcing rule on top of this .htaccess just below RewriteBase / line:

      RewriteCond %{HTTP_HOST} !^www. [NC]
      RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [NE,R=301,L]
      
    2. Make sure in your permalink settings of WP you have blog address with www