Permalinks: Identical code, different servers, one interrupts 301 redirects

3 posts by 2 authors in: Forums > CMS Builder
Last Post: February 26, 2014   (RSS)

By benedict - February 25, 2014

Hi guys,

I'm using the same .htaccess code with your permalinks code, and while permalinks works on both, the subsequent 301 redirects do not work on one of the servers. When I remove the permalinks code, the 301 redirects work fine. I presume there is a server setting adjustment I need to make. Any ideas?

# Add this to an .htaccess file in your website root folder
# Your website root folder is usually named: htdocs, httpdocs, www, html, or just / in FTP

# START: CMS Permalink Code
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^permalinks_dispatcher\.php$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /cmsAdmin/plugins/permalinks/permalinks_dispatcher.php [L]
</IfModule>
# END: CMS Permalink Code

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteEngine On

## 301 Redirects
# 301 Redirect 1
RewriteCond %{QUERY_STRING}  ^Samples-4$ [NC]
RewriteRule ^nonslip-products\.php$ /samples? [R=301,NE,NC,L]

Cheers & thanks in advance.

By Dave - February 26, 2014

Hi Benedict,

Can you try re-ordering the file like this?

## 301 Redirects
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteCond %{QUERY_STRING}  ^Samples-4$ [NC]
RewriteRule ^nonslip-products\.php$ /samples? [R=301,NE,NC,L]

# START: CMS Permalink Code
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^permalinks_dispatcher\.php$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /cmsAdmin/plugins/permalinks/permalinks_dispatcher.php [L]
</IfModule>
# END: CMS Permalink Code

Basically we want to run all your code in this case before permalinks.

Let me know if that works for you or gets you any closer. 

Dave Edis - Senior Developer
interactivetools.com