Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Filter by Categories
Accounts
Articles / Notes
Biology
Chemistry
Computer Class
Daily Current Affairs
English
General Knowledge
History
Indian Law
Interview Questions
Mathematics
Muft Shiksha - Free Education
Science

Generic htaccess redirect www to non-www

0
0 Comments

I would like to redirect www.example.com to example.com. The following htaccess code makes this happen:

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

But, is there a way to do this in a generic fashion without hard coding the domain name?

Akbar Khan Answered question 5 Apr, 2024
Add a Comment
Join for Teach