문제

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