6 votes
Accepted

Explanation of new line in htaccess file: RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?

This isn't really a complete answer, as I can't comment specifically on how/where Ballot169 fits into the bigger scheme of things. However, I can comment on "what it does". It does seem a bit odd ...
MrWhite's user avatar
  • 13k
5 votes
Accepted

Apache: Don't log errors for certain non-existing files (regular file or symbolic link)

If you are getting "File does not exist" messages in your "error log" then the LogLevel (as set in the server config) is arguably set "too high". Certainly, too high for ...
MrWhite's user avatar
  • 13k
5 votes

Drop trailing slash in apache for directory

If you remove the slash on a directory and still expect the directory index document (in that directory) to be returned then you'll need to manually "fix" the URL by internally rewriting to the index ...
MrWhite's user avatar
  • 13k
3 votes
Accepted

Apache rewrite to extract multiple pieces of data from original request URL

You are very close to what you like to have, you only missing ( & ) RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.com$ RewriteCond %{REQUEST_URI} \.(mp4|mp3|mov|mpg|mpeg|webm|wmv|ogg)$ [NC] RewriteRule ...
Webdesigner's user avatar
3 votes

Why doesn't this .htaccess file redirect properly?

Exceptions like this are easier to apply as final rules that don't do any rewriting. Replace your RewriteCond line with: RewriteRule ^pma/ - [L] RewriteRule ^css/ - [L]
David's user avatar
  • 626
3 votes

Why doesn't this .htaccess file redirect properly?

RewriteCond only applies to the next RewriteRule. You now have two rules, each of which need the exception. So just repeat that RewriteCond line like this: #Redirect all /[pagename] requests (with ...
Cedric Knight's user avatar
2 votes

Redirect all the traffic from multiple domains to single domain using htaccess

Adding the below apache rewrite rules should do the trick for you. RewriteEngine On RewriteBase / # first redirect RewriteCond %{HTTP_HOST} !domain.com$ [NC] RewriteRule ^(.*)$ https://newdomain.com/...
krt's user avatar
  • 284
2 votes
Accepted

how would i create rule for a particular subdomain in uppercase? e.g XX.test.com

To be more precise, you CAN tell Apache, for instance, to redirect to a certain format, but then (at least some) browsers get confused because it asks for the lowercase version of the domain and gets ...
ondelettes's user avatar
2 votes
Accepted

.htaccess is stopping a site from works while WP sites does work, why?

What is important is the underlying file/directory structure. If these 3 sites are essentially on the same account - the same parent directory - then each site is probably in a separate subdirectory (...
MrWhite's user avatar
  • 13k
2 votes

.htaccess is stopping a site from works while WP sites does work, why?

create .htaccess file for your standalone PHP application that will redirect your code to subsite.example.net
Sukhjinder Singh's user avatar
2 votes
Accepted

Unsure what this .htaccess set of rules is doing

Just to add to OverCoder's answer... as already stated, this code removes the slash at the end of the URL (except for directories) ... RewriteCond %{REQUEST_URI} /$ RewriteCond %{REQUEST_FILENAME} !-...
MrWhite's user avatar
  • 13k
2 votes

Unsure what this .htaccess set of rules is doing

It removes the slash at the end of any URL e.g.: https://example.com/welcome/ becomes: https://example.com/welcome The second RewriteCond specifies that the rule only matches when the URL does ...
OverCoder's user avatar
  • 143
2 votes
Accepted

Add www to domain but not for a specific domain

As with your other condition, checking for the presence of www in the host, you need to check against the HTTP_HOST server variable again, not REQUEST_URI - which only holds the URL-path. Try the ...
MrWhite's user avatar
  • 13k
2 votes
Accepted

RewriteMap inside RewriteCond doesn't work (Apache)

RewriteCond "%{QUERY_STRING}" !^v=${versions:version} This doesn't work because the CondPattern (2nd argument to the RewriteCond directive) is a regex and consequently does not support ...
MrWhite's user avatar
  • 13k
2 votes
Accepted

GeoIP: Redirect all but specific countries

You could simply use negation ! to redirect anything but China CN and Russia RU. RewriteEngine on RewriteCond %{ENV:GEOIP_COUNTRY_CODE} !^(CN|RU)$ RewriteRule ^(.*)$ https://example.com/us/$1 [L]
Esa Jokinen's user avatar
  • 49.8k
2 votes
Accepted

htaccess rewrite rule not working with file extentions

The reason is the following block in nginx configuration: location ~.*\.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|html|htm|txt|js|css|exe|zip|tar|rar|gz|tgz|bz2|...
Tero Kilkanen's user avatar
1 vote
Accepted

Should I escape slash '/' in RewriteCond?

Should I escape the slash / in RewriteCond? By "escape the slash", you really mean "should I match a URL encoded slash or not?". This depends entirely on the HTTP request being ...
MrWhite's user avatar
  • 13k
1 vote

Rewriterule not working with Joomla urls due to question mark and other special characters, also due to long urls

To 301 redirect /component/adsmanager/?view=list&catid=0&rootid=0&Itemid=1000 to /newurl you would use the following mod_rewrite directive near the top of your .htaccess file: RewriteCond %...
MrWhite's user avatar
  • 13k
1 vote
Accepted

htaccess file to perform specific rules to different domains

You seem to be behind an SSL proxy(?), hence the use of the X-Forwarded-Proto request header, instead of the HTTPS server variable. RewriteCond %{REQUEST_URI} !(health_check\.php)$ RewriteCond %{...
MrWhite's user avatar
  • 13k
1 vote
Accepted

Configuring www.domain.com and domain.com with zonefile or letsencrypt to always forward to domain.com

Clients arrive to https://www.example.com so even if you make a redirect to https://example.com you need two SSL certificates (one for example.com and the other for www.example.com) or a single SSL ...
Mat's user avatar
  • 1,903
1 vote

htaccess - .htaccess in sub directory not inheriting .htaccess in root directory

I just had the same issue - I resolved it by using RewriteOptions InheritBefore instead of just RewriteOptions Inherit so the .htaccess file in the parent directory was processed before the one in the ...
b4tch's user avatar
  • 111
1 vote
Accepted

Apache doesn't match rewritten URL as regular file

RewriteCond: input='/htdocs/foo/bar.php' pattern='!-f' => matched Not sure if this has been over-exemplified, but unless there is "something else" going on, this is not as expected, given the ...
MrWhite's user avatar
  • 13k
1 vote

Explanation of new line in htaccess file: RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?

@MrWhite I appreciate your guidance on how to respond, add more context etc, and per your suggestion I am answering my question so you can add your comments to it, thank you. <:>:<:>:<:>:<...
Kenneth Poveda Mata's user avatar
1 vote

Nginx location match if not equal

Nginx If Generally with Nginx you avoid using the IF statement. It takes more resources and doesn't always work how you want. Solution The way you do this is to define two locations, catchall and ...
Tim's user avatar
  • 32.8k
1 vote

Updated SSL certs and now rewrite conditions no longer working for apache2

Troubleshooting suggestions: Please confirm your environment: Ubuntu 14.04 server with Apache2 v2.4.7. Your httpd.conf is configured to serve both HTTP (:80) and HTTPS (:443). Your certificate ...
paulsm4's user avatar
  • 270
1 vote

Updated SSL certs and now rewrite conditions no longer working for apache2

On your <VirtualHost *:443> you enable HSTS. That tells the browser to internally rewrite every request for the domain to HTTPS. After this, there's no use for the RewriteCond %{REQUEST_URI} !^/...
Esa Jokinen's user avatar
  • 49.8k
1 vote

Why are Apache Rewrite Conditions not working?

The WordPress directives are at the bottom of the .htaccess file, while I've put mine at the top. That is correct. RewriteCond %{HTTP_REFERER} domain.tracker.com [NC] There is nothing actually ...
MrWhite's user avatar
  • 13k
1 vote

Rewrite cond for domain and www.domain letsencrypt

Let's take a look at this line: RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] Here, the %{SERVER_NAME} variable depends on the UseCanonicalName, by default set Off. ...
Esa Jokinen's user avatar
  • 49.8k
1 vote
Accepted

rewrite / restrict specific domain name in apache

You can do this using mod_rewrite which allows you to check the host through which the site is being accessed. Try the following, in your server config (or <Directory> section or .htaccess file):...
MrWhite's user avatar
  • 13k

Only top scored, non community-wiki answers of a minimum length are eligible