I had the same problem (trouble stripping ‘www’ from URLs that point to a sub-directory on an add-on domain), but after some trial and error, this seems to work for me:
RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]
Related Posts:
- How to remove .html from URL?
- How to remove .html from URL?
- Generic htaccess redirect www to non-www
- How can I use an .htaccess file in Nginx?
- Change PHP version on server using either .htaccess or php.ini
- .htaccess – how to force “www.” in a generic way?
- Access-Control-Allow-Origin Multiple Origin Domains?
- htaccess – Redirect to subfolder without changing browser URL
- wordpress image upload error and htaccess rule explanation
- How does RewriteBase work in .htaccess
- .htaccess deny from all
- Server unable to read htaccess file, denying access to be safe
- Getting a 500 Internal Server Error on Laravel 5+ Ubuntu 14.04
- Redirect non-www to www in .htaccess
- Using Errordocument 401 leads to blank page
- How to modify HTACCESS file for non-WordPress documents
- Masking wp-content/themes/name/images to just images directory using htaccess
- WordPress on a subdirectory of Laravel – WordPress pretty permalinks inner page shows laravel
- Place static HTML files in path below WordPress page
- htaccess rewrite for author query string when WP is in subfolder
- How to map permalinks with accented letters to sanitized slugs?
- Remove year and month in URL using .htaccess
- Bypass .htaccess when using download_url
- Removing rules from .htaccess
- .htaccess rewrite rule for removing .php extension with exception of wp login and wp-admin
- Rewrite rule not working
- Cache Busting using htaccess Rewrite rule?
- WordPress multisite causing Error 101 (net::ERR_CONNECTION_RESET): Unknown error [duplicate]
- .htaccess redirects disappeared after re-saving permalinks
- Protect Upload Folder Files With Ampersand Problem
- Remove File Extension for Page Outside of WordPress
- WordPress URL/Folder ReWrite using Htaccess
- WordPress mod_rewrite is canceling/overwriting my other mod_rewrite rule
- How to rewrite WordPress uploads folder to another folder using htaccess
- Menu links only using http after enabling https, unable to redirect http links
- How to protect media directory with .htaccess?
- How to create a 301 redirect that doesn’t apply to subsites
- Why does multisite bypass WordPress for wp-content, wp-admin, wp-includes and .php files?
- Rewrite rule to load images from production does nothing
- Remove base slug in permalinks of hierarchical custom post type
- WordPress rewrite rules don’t need ^?
- How can i redirect one url to another url using .htaccess or add_rewrite_rule
- Override htacces rule only for specific directory
- Adding rewrite rules directly to .htaccess file
- .htaccess rule to redirect old URLs to new structure [closed]
- Add additional non-rewrite .htaccess directives on multisites via mod_rewrite_rules filter
- Only default permalink is working mod_rewrite enabled
- mod_rewrite loop, redirecting http to https on certain section of wordpress blog
- a one-off rewrite rule
- blocking access to all post/tag URIs via htaccess
- Change htaccess to redirect to index.php in subfolder
- .htaccess rules for blocking bots with an extra condition
- How to remove wordpress directory slash
- Wrong Redirect/Rewrite Rules?
- Site in subfolder – all pages work except home
- Redirections and rewrites to subdomain
- htaccess, site and staging in subdirectories
- How to write .htaccess so that https is on for subpages only but not the home page
- Rewriting “pretty” blog category URL with htaccess / add_rewrite_rule() causes 404 page
- How To Fix A Redirect Chain
- How to create a redirect in the .htaccess file, with 2 exceptions
- 404 error Additionally 403 Forbidden error on a URL
- Map secondary domain to other’s virtual subfolder
- Mod_Rewrite to show only last subcategory in URL
- Custom rewrite rule, url returning 404
- Loading index.php contents which located outside blog folder for post single page
- mod_rewrite doesn’t work as I want even with JSON API Plugin disabled
- I have a page using a pretty url and a mod_rewrite rule matching it. I expected it to give an error but it’s working. Why?
- Redirect – remove custom query string
- mod-rewrite exception? keep #hash in matching urls?
- .htaccess rewriterule being ignored – tyring to remove dates from WP posts
- .htaccess Non-‘www’ to ‘www’ Subdomain Redirection Only Works for Homepage
- WordPress and Htaccess
- force www rewrite if wordpress put in a folder
- Simple seo-friendly custom $_GET url rewrite with htaccess
- How do I make WordPress revise an .htaccess file a certain way?
- How can I create a smarter .htaccess file that will add a directory?
- mod-rewrite rules grabs “broken permalinks”, too
- Rewriting subfolders to specific parent folder in WordPress
- Understanding Redirects
- Redirect WordPress site to a landing (construction) page using htaccess, with access to /wp-admin and /invoice
- htaccess redirect to path
- Can I add a rewrite rule in htaccess to remove the multisite subdirectory from the URL?
- Pretty URL via Rewrite
- URL Rewrite 404
- using htaccess to check for cookie on permalink then conditionall rewrite with query parameter
- htaccess question and plugins.php
- Cannot get 301 redirection in htaccess to work (either Redirect or Rewrite)
- htaccess and redirect to new url using regex
- I can access subdirectory, but not files within it
- Pretty permalinks (again)
- ModRewrite not working properly
- Redirect homepage /page/1/ to /blog/page/1/
- htaccess mod_rewrite not working
- customize urls displayed by previous_post_link and next_post_link
- .htaccess not working in WordPress
- Add-on domain works in WordPress but links still lead to subdomain
- Can’t get pretty permalinks to work without index.php
- How to redirect a virtual page (e.g. /blog) to the home page?
- Add rewrite endpoint and .htaccess