Reputation: 25
I'm running php on IIS 8.0.
when I enter the site address with www server returns IIS Error 500. with out www everything is OK.
How can I automatically remove www from adress.
Upvotes: 0
Views: 112
Reputation: 111
You don't want to simply redirect because you will have to do that for every page and subdomain. My code will auto strip the www. for you.
.htaccess code
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]
If you want to fix you DNS issue just add a 'A' record with www.yourwebsite.com
Upvotes: 1
Reputation: 478
you can use url rewrite module
add this code to web.config and replace domain.tld with your domain name
<rule name="Remove www" stopProcessing="true">
<match url="^(.*)$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" />
</conditions>
<action type="Redirect" url="http://domain.tld{PATH_INFO}" />
</rule>
Upvotes: 1
Reputation: 7688
There are multiple ways to redirect your site to domain only, 1) using DNS server, in DNS you can redirect your visitors to domain only, 2) using IIS config file -> C:\Windows\System32\inetsrv\config.
Upvotes: 1