Questions tagged [rewritecond]
136 questions
10
votes
3 answers
How do I make RewriteCond %{HTTP_COOKIE} match a cookie value exactly?
How do I make my rule match an exact value of a cookie? I've tried:
RewriteCond %{HTTP_COOKIE} ^its=me$ [NC]
RewriteCond %{HTTP_COOKIE} its=^me$ [NC]
RewriteCond %{HTTP_COOKIE} its="me" [NC]
RewriteCond %{HTTP_COOKIE} its=me [NC]
The last…
Nick
- 4,726
6
votes
1 answer
How do I reset Apache's RewriteCond directive?
I have some Apache configuration like this:
# Image hotlinking rule
RewriteCond %{HTTP_REFERER} ^http://badsite\.com/
RewriteRule .*/static/artwork/.*\.(jpg|png)$ /static/images/hotlink.png [L]
# Redirects
RewriteRule ^static/artwork/(.+)$ …
DisgruntledGoat
- 2,689
4
votes
1 answer
rewrite / restrict specific domain name in apache
We have https://example1.com/login and example2.com/login being hosted from the same apache server (2.2.22). I want to restrict /login on example1.com.
example1.com/login --> 404 (preferably) or 403
example2.com/login --> login page
I…
akay
- 53
4
votes
1 answer
Drop trailing slash in apache for directory
I have the following url www.example.com/advice/ now notice the trailing slash at the end of the url? I would like that to be removed to be something like www.example.com/advice. Now when I enter that URL in the browser I get redirected to the with…
Steve
- 145
3
votes
2 answers
Explanation of new line in htaccess file: RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
Recently I noticed that a new line was added in the htaccess file in several locations throughout the file.
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
I don't understand what it does, and I would like clarification…
3
votes
3 answers
Updated SSL certs and now rewrite conditions no longer working for apache2
I'm running an Ubuntu 14.04 server with Apache2 v2.4.7.
Recently our site was getting errors from Chrome saying we needed to update our certs. I just completed that earlier this week, updating the SSL Certs and then restarting Apache. A couple of…
risa_risa
- 131
- 5
3
votes
1 answer
Apache rewrite to extract multiple pieces of data from original request URL
Trying to create an Apache rewrite that applies to video files only, over to a dedicated video-serving web-server.
It requires rewrite logic that extracts multiple pieces of information from the original request, including HTTP_HOST domain name,…
K.McCallum
- 33
- 6
3
votes
1 answer
ProxyPass if RewriteCond is TRUE
At proxypass configuration file I have written this line
ProxyPass /directory/ ajp://localhost:8009/directory/
It works perfectly
At htaccess file
RewriteRule ^seconddirectory/(.*)$ http://domain.com.localhost/directory/$1 [P]
P flag implies…
Jvrq
- 75
3
votes
1 answer
Trouble with www. redirect (.htaccess)
I'm trying to get a simple www. to non www. redirect set up. Here's the .htaccess
DirectoryIndex index.php
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain.org [NC]
RewriteRule ^(.*)$ http://domain.org/$1 [L,R=301]
RewriteBase /
##########…
a coder
- 819
3
votes
2 answers
One RewriteCond for multiple RewriteRules
I need to preserve all user query strings.
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^$ index.html?page=home&%1
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^about$ index.html?page=about&%1
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule…
MotionGrafika
- 203
- 1
- 3
- 5
3
votes
1 answer
How to exclude a sub-folder from HTaccess RewriteRule
I have WordPress installed in my root directory, for which a RewriteRule is in place.
I need to password-protect a subfolder ("blue"), so I set the htaccess in that folder as such.
Problem is that the root htaccess RewriteRule is applying to "blue"…
amb9800
- 31
2
votes
1 answer
Nginx location match if not equal
I have www.example.com/test and i want to write a condition if requested url is not equal to /test do a rewrite or redirect to www.example.com. The closest i can get is a code below but when i want to use www.example.com/test without / at the end it…
justdoole
- 21
2
votes
0 answers
Multiple rewritecond with different variables
I am trying to match on two different things in a single request to proxy a request to a different server.
My rewrite conditions are:
RewriteCond %{QUERY_STRING} (token=.*)$
RewriteCond %{HTTP_COOKIE} (lb[1-4]\.domain\.com\:(\d+))
My problem is…
hacktek
- 21
2
votes
1 answer
GeoIP: Redirect all but specific countries
I am using Apache's GeoIP module and a MaxMind database to determine the country of a visitor based on their IP address and redirecting them to a country sub-folder as shown below:
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^US$
RewriteRule ^(.*)$…
Ralph
- 952
2
votes
1 answer
Why HTACCESS RewriteCond %{HTTP_COOKIE} only for php and not working for html?
I was trying to redirect all direct access in my subfolder using this code
RewriteEngine on
RewriteCond %{HTTP_COOKIE} !user_cookie=[^;]
RewriteRule .* http://webhost.org/ [R=301,L]
I realise it was working only for OHP files but not for other…
MyFault
- 21