Questions tagged [rewritecond]
128 questions
9
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,433
- 29
- 67
- 95
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,569
- 4
- 26
- 34
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
- 1
- 5
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
- 5
3
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
- 135
- 1
- 5
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
- 1
- 5
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
- 719
- 4
- 20
- 37
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
- 2
- 3
2
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…
Kenneth Poveda Mata
- 49
- 1
- 8
2
votes
0 answers
Rewrite rule loses query parameters
I have a webserver running apache2 with php7.
In my apache config, there is a redirect rule like the following:
RewriteCond %{HTTP_HOST} !^www.*
RewriteRule .* %{HTTP:X-Forwarded-Proto}://www.%{HTTP_HOST}%{REQUEST_URI} [QSA,R=301,L]
This should…
Stephan Richter
- 191
- 11
2
votes
2 answers
.htaccess is stopping a site from works while WP sites does work, why?
I have three sites running in a shared hosting (Bluehost) with a dedicated IP address. The description is as follow:
example.com => this is the main site and domain, is a WP
example.net => this is an add-on domain (don't know if you're familiar…
ReynierPM
- 700
- 5
- 14
- 28
2
votes
1 answer
Something like foreach in htaccesss?
I am in this situation:
url: domain/var1/var2/var3/.../varn
And I want to change that url in:
url: domain?v1=var1&v2=var2&v3=var3/.../&vn=varn
I found this way:
RewriteRule domain/([^/]+)/([^/]+)$ domain/index.php?v1=$1&v2=$2 [QSA,NC]
But as you…
Francesco
- 121
- 3
2
votes
1 answer
How to exclude one subfolder from my RewriteRule Htaccess rules?
I have a .htaccess in my root of website that looks like this:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.mydomain\.pl [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?([a-z0-9_-]+)\.mydomain\.pl [NC]
RewriteRule ^/?$ /index.php?run=places/%1…
Tom Smykowski
- 1,115
- 5
- 19
- 27