New answers tagged

2

For your non-www you forgot RewriteCond %{HTTPS} =on So try: RewriteCond %{HTTP_HOST} ^www.example.com$ [NC] RewriteCond %{HTTPS} =on RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]


2

In response to MrWhite's comment, I found out how to see the redirect chain in the browser mimiced what ahrefs was saying. When I took out the ruleset to remove the www, it works fine. #remove www from https #RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] #RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [R=301,QSA,NC,L] I would still like to remove www. Further ...


17

A link like <a href="www.example.software"> is defined by the HTML/HTTP spec as a relative link. If you are currently on https://www.example.software/ it would result in the URL https://www.example.software/www.example.software. If you are currently on https://www.example.software/foo/some-page.html it would result in the URL https://www....


3

Since version 2.4.16 RewriteBase directive is not required when the request is mapped via Alias. Basically it means that if you have multiple Alias DocumentRoot /var/www/html Alias /siteA /var/www/docroot Alias /siteB /var/www/docroot Before 2.4.16 you need to specify the RewriteBase with some gimmick in .htaccess or use the Symphony way as suggested by @...


3

It isn't the server that is remembering you, it is the client. When you log in with Basic Authentication or Digest Authentication, the browser remembers your login credentials and sends them with each and every request to the server. Browsers typically remember this information until the browser is restarted and give the web server no control. It is not ...


4

You may want to read on Basic Authentication. From that article: Server side When the server wants the user agent to authenticate itself towards the server after receiving an unauthenticated request, it must send a response with a HTTP 401 Unauthorized status line[5] and a WWW-Authenticate header field.[6] The WWW-Authenticate header field for basic ...


3

In addition to Apache/mod_rewrite, some of this behaviour can be the result of the browser and how the OS maps the request to the filesystem. But as noted in comments, a "testing tool" can also result in (incorrect/unclear) behaviour that is unique to that tool. To clarify, this is .htaccess in the document root (a directory context). If these ...


0

RewriteRule ^/this%20file.pdf http://www.example.com/ The URL-path matched by the RewriteRule pattern (regex) is already %-decoded. So, to match an encoded space (ie. %20) in the request you match against a literal space in the regex. (Aside: If you try to match a literal %20 here then you are matching against a doubly-encoded space, ie. %2520, in the ...


Top 50 recent answers are included