Remove www from the url - .htaccess

Does anyone have the setttings from the .htaccess file to remove www from my url?
http://example.com
I've tried using some of the settings in the internet but it gives me a redirect loop. I need something that prevents a redirect loop.
this would really help me. thank you

You can put this code in your htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
If you're still having a redirect loop:
you have maybe another script that redirects non-www to www
old rule still in browser's cache (try cleaning cache or with another browser)

Related

one htaccess for multiple domain, redirect problem

I have multiple domains and one htaccess for these. We split off some content from domain1.com to domain2.com and I need to redirect to the new page.
Redirect 301 /folder/page.html https://www.domain2.com/folder/page.html
resulted in a infinity loop ... i also tried this but its dont work:
RewriteCond %{HTTP_HOST} ^domain1.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain1.com$
RewriteRule ^/folder/page.html https://www.domain2.com/folder/page.html [R=301,L]
I also need to mention that not all pages from domain1 should redirect to domain2 but it would be ok if the whole folder is redirected
my knowledge of htaccess isnt that big hope you can help me!
Based on your shown samples, could you please try following. Please place this to the top of your htaccess file.
Also please make sure to clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteCond %{HTTP_HOST} ^(www\.)?domain1\.com$ [NC]
RewriteRule ^folder/page\.html https://www.domain2.com/folder/page.html [R=301,NC,L]

Redirect all webpages to www with .htaccess

I've been trying to redirect my subdomain pages to force them to be at www.
The thing is, if I try example.example.com it will perfectly redirect to www.example.example.com, in the other hand, if I try example.example.com/whatever.html it won't redirect. My .htaccess file looks something like this:
RewriteEngine On
#subdomain non-www to www
RewriteCond %{HTTP_HOST} ^example.example.com$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [NC,L,R]
Any ideas? Thanks guys!
Try removing the $ from the RewriteCond line.

Joomla 2.5 Mijoshop Redirect Loop

The issue i'm encountering is as follows: When the Joomla backend is logged into, there's no problems, however upon going to Extend->MijoShop->Dashboard a redirect loop is thrown. At this point if you refresh the page it allows you through to the dashboard, and the redirect loop won't be thrown again for that browser session.
Based on some research I was attempting to force non-www to www and www to non-www with poor results in the .htacess file. A nudge in the right direction would be greatly appreciated. No other parts of the site are presenting loops.
Seem that something is wrong with your .htaccess file. Please try to put the default joomla .htaccess and use this rule for the non www to www redirection:
Force the www.
RewriteCond %{HTTP_HOST} ^your-site.com [NC]
RewriteRule ^(.*)$ http://www.your-site.com/$1 [L,R=301]
Remove the www.
RewriteCond %{HTTP_HOST} !^your-site.com$ [NC]
RewriteRule ^(.*)$ http://your-site.com/$1 [L,R=301]
full tutorial could be found here

How to .htaccess - Redirect only one page with out www

htaccess - Redirect to with NOn www to www
it is fine fine but i want only particular page to open with out www how i have to open say me the solution it is like this
http://www.yourdomain.com/score/MarioRide/submit.php
i need above page with out WWW how i have to do pls help me like this
http://yourdomain.com/score/MarioRide/submit.php
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.yourdomain.com$ [NC]
RewriteRule ^score/MarioRide/submit.php$ http://yourdomain.com/score/MarioRide/submit.php [L,R=301]

.htaccess redirect non-www to www problem

I'm using the following .htaccess file to do few mod-rewrites and also redirect visitors from non-www to www. But the problem is, when someone visit http://domain.com/terms it redirects them to http://www.domain.com/document_terms.php by ignoring the 3rd line.
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^terms$ document_terms.php
RewriteRule ^privacy$ document_privacy.php
RewriteCond %{HTTP_HOST} !^www
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
Is there a way to fix this?
You just need to change the order of your rules so the www rewriting comes first.

Resources