I have a plugin to set up permalinks on my site however it only works when lead by www in front of the address. All other site addresses function fine with our without the leading www. I've been playing around my htaccess file but can't figure out how to fix this. The first portion is generated by the plugin, while I inserted the last 2 lines. Any suggestions on how to fix this? The last condition on my file seems to be getting ignored by all the permalinks.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^permalinks_dispatcher\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /cms/plugins/permalinks_dispatcher.php [L]


RewriteCond %{HTTP_HOST} ^mydomain.com
RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L]
</IfModule>
有帮助吗?

解决方案

You only have to begin with your www-rule first

<IfModule mod_rewrite.c>
RewriteEngine On

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

RewriteRule ^permalinks_dispatcher\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ /cms/plugins/permalinks_dispatcher.php [L]

</IfModule>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top