64011

rewrite https and www

Question:

now I have a website https.

<a href="http://www.example.com" rel="nofollow">http://www.example.com</a> -> <a href="https://www.example.com" rel="nofollow">https://www.example.com</a> = OK !

But, I have a problem with <strong>www</strong> ://example.com -> s://example.com = not good

I would like to have this redirection below : ://example.com -> s://www.example.com

How with RewriteCond and RewriteRule ? Help me plz !

Thanks !

Answer1:

To enforce https on all requests and redirect to <em>www</em>.example.com

# force https and www RewriteCond %{HTTPS} off RewriteRule ^ https://www.example.com%{REQUEST_URI} [R,L] # if already https without www RewriteCond %{HTTPS} on RewriteCond %{HTTP_HOST} ^example.com$ RewriteRule ^ https://www.example.com%{REQUEST_URI} [R,L]

Recommend

  • Yii, change homeUrl
  • expanding regex in Python
  • How to Write 404 Redirected .htaccess code?
  • How to split comma and semicolon separated string into a two dimensional array
  • url rewrite not working .htaccess
  • Strip down any parameter from URL which is not whitelisted
  • Use htaccess to mask domain and folder name
  • request follow redirection without post data
  • Office365 authentication without login redirection
  • htaccess settings for angularJS pushstate
  • Mod rewrite redirection to another domain if file not exist
  • Redirect to trailng slash (htaccess)
  • Javascript unload page condition
  • Create registry key in 32-bit hive on x64 PC using Installshield 2012 LE - Avoid redirection
  • Apache RewriteRule redirection with url encoded
  • htaccess add www if not subdomain, if subdomain remove www
  • How to run “Deployd” on port 80 instead of port 5000 in webserver.
  • Typescript - Unable to get 'import' statement to function
  • Is there any way to access browser form field suggestions from JavaScript?
  • Different response to non-authenticated users and AJAX calls
  • RectangularRangeIndicator format like triangular using dojo
  • C# - Serializing and deserializing static member
  • Cross-Platform Protobuf Serialization
  • Incrementing object id automatically JS constructor (static method and variable)
  • Join two tables and save into third-sql
  • How to model a transition system with SPIN
  • ORA-29908: missing primary invocation for ancillary operator
  • Do create extension work in single-user mode in postgres?
  • bootstrap to use multiple ng-app
  • How to get icons for entities from eclipse?
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • Revoking OAuth Access Token Results in 404 Not Found
  • Turn off referential integrity in Derby? is it possible?
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • JaxB to read class hierarchy
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Converting MP3 duration time
  • Conditional In-Line CSS for IE and Others?