PermaLinks conflict

8 posts by 5 authors in: Forums > CMS Builder
Last Post: February 11   (RSS)

Hello i'am using perma links and the admin folder is rewritten with the dispatcher ,any idea what the issue is? i'm moved the dispatcher to the roor directory as im protecting the admin folder with password

Hi moh3, 

So in .htaccess we have something like this that checks to the see if the URL or permalink exists as a file or directory.  If it doesn't it passes the request to the dispatcher: 

### Pass URL to permalinks dispatcher (do this last after any other redirects)
RewriteRule ^permalinks_dispatcher\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /cmsb/plugins/permalinks/permalinks_dispatcher.php [L]

But if you're password protecting your admin folder with .htaccess and .htpasswd, that can interfere with the directory detection and redirect.

You can try adding a condition to skip your admin folder when processing permalinks.  Something like this: 

### Pass URL to permalinks dispatcher (do this last after any other redirects)
RewriteRule ^permalinks_dispatcher\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/cmsb/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /cmsb/plugins/permalinks/permalinks_dispatcher.php [L]

Let me know if that works for you!

Dave Edis - Senior Developer
interactivetools.com

personally I set my htaccess rules to enforce the trailing slash, much cleaner in the long run as that is what the permalinks expects, still solves the seo noise

Jeff Shields
yaadev.com

Same here, Jeff. I got tired of Google fighting me with canonical issues so everything gets a slash at the end

Thanks,

Kenny H

So, to enforce the slash at the end of domain urls, in .htaccess you have something like this at the top (or above any kind of cms rules...like with WP)?

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Exclude actual files from the rule
RewriteCond %{REQUEST_FILENAME} !-f
# Redirect to trailing slash if not ending with one
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ https://yourdomain.com/$1/ [L,R=301]
</IfModule>

It doesn't need to be quite so specific, this will do it nicely:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^(.*)$ /$1/ [R=301,L]
Jeff Shields
yaadev.com

Thanks Jeff!