Questions tagged [rewritecond]

128 questions
2
votes
1 answer

apache httpd keep sending http requests to strange IPs

Recently I noticed my server keeps sending data to strange location "121.11.76.48" by netstat -na . To find out what it is sending , I tried : tcpdump -i eth0 host 121.11.76.48 -nnvvXSs 1514 And found it keeps sending HTTP requests to this location…
smallufo
  • 199
  • 2
  • 8
2
votes
1 answer

unique .htaccess question about mod_rewrite and RewriteCond

I have a few rewrite rules like these RewriteRule ^dir/(.*)-something.html otherdir/file1.php?var1=val&var2=$1 [L,NC] RewriteRule ^dir/ otherdir/file2.php?var1=val [L,NC] dir/ is not a real directory. Everything above works as expected. However,…
Stephen
  • 127
  • 1
  • 5
2
votes
1 answer

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

I want to prevent Apache from logging "File does not exist" errors for certain irrelevant non-existing files that are often requested, such as "apple-touch-icon-120x120.png". These log entries clutter my log and make it difficult to see "real"…
2
votes
1 answer

RewriteMap inside RewriteCond doesn't work (Apache)

I have a RewriteCond that checks if {QUERY_STRING} contains the right version number, if it doesn't then redirect users to the correct version. For instance if v0.7 is the latest, users accessing http://localhost/?v=0.5 should be redirected to…
James Wong
  • 165
  • 8
1
vote
1 answer

Conditional String Htaccess

I need to validate that an environment variable exists and that the value is equal to "cloudflare", in case there is no deny access. I have done multiple tests, and I have not been able to make it work. This is my test code. RewriteEngine on …
SolucionTi
  • 11
  • 1
1
vote
1 answer

htaccess rewrite country without subdomains

i need to rewrite URL from us.example.com to example.com?country=us without subdomains I tried these 2 rules: 1. RewriteRule (US|EG) ?c=$1 [NC , L] 2. RewriteRule :\/\/(.*?).example.com ?C=$1 [NC , L] but they didn't work. so .. is there any…
1
vote
1 answer

Apache doesn't match rewritten URL as regular file

I've setup a .htaccess to redirect requests against the containing directory /htdocs/foo to the file bar.php. 1st of all: I know how to achieve this in general, but for reasons out of my control the .htaccess also wants to check if the URL resolves…
Thorsten
  • 13
  • 3
1
vote
1 answer

Apache RewriteEngine config purpose

I ran into this snippet in an Apache config file that someone else wrote, but I'm not sure of the purpose. Could anyone explain what this is for? RewriteEngine On RewriteCond %{THE_REQUEST} !HTTP/1\.1$ RewriteRule .* - [F]
FluffyBeing
  • 113
  • 3
1
vote
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
  • 11
  • 1
  • 1
  • 2
1
vote
1 answer

Why are Apache Rewrite Conditions not working?

I tried to perform a redirect writing in .htaccess file: RewriteEngine on RewriteRule article-1 www.another-site.com/article-1 [R=301,L,NC] and it works correctly. Anyway, when I add a rewrite condition, for example: RewriteEngine on RewriteCond…
Arthu83
  • 11
  • 1
  • 2
1
vote
1 answer

Apache Redirect to /index.php - How to handle direct requests for /index.php

I'm not 100% sure if this should be on server fault or stack overflow, though I'm leaning towards server fault. Most PHP frameworks utilize Apache redirects to funnel all request to /index.php and then the framework handles the routing from there. …
d.lanza38
  • 327
  • 1
  • 5
  • 13
1
vote
1 answer

Conditional http redirect to https depending on site URL? (Apache)

I have a url that is used to store data across multiple sites based on client ID. Many of our clients are now wanting to use secure https resolution, yet the data referenced on their sites from this specific url is not currently secure, therefore…
David W.
  • 11
  • 1
1
vote
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
  • 11
  • 2
1
vote
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
  • 802
  • 11
  • 25
1
vote
1 answer

htaccess file to perform specific rules to different domains

I have one application with is server over a number of domains (each customizes the appearance of the application. In addition, there is a common domain which has multiple subdomains to display the same data as above. So - www.apples.com appears the…
Tom
  • 133
  • 6
1
2
3
8 9