Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [rewritecond]

The tag has no usage guidance.

0
votes
0answers
536 views

Apache RewriteMap DB to match against list on RewriteCond

how to check url exist in some external file . Just checking given request URI is in the list of vanity urls. Vanity url's file present at /mnt/var/www/html/vanity_urls.txt RewriteMap vanityurls ...
1
vote
2answers
91 views

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 ...
0
votes
0answers
13 views

Apache 2.15, mod_rewrite and rewrite map - dealing with query strings and escaped characters

I've been given a series of URLs that require 301 redirects for SEO purposes, and I'm trying to figure out how to make use of Apache's rewrite function in order to deal with source URLs with query ...
1
vote
1answer
20 views

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\....
0
votes
1answer
1k views

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 ...
3
votes
3answers
118 views

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 ...
1
vote
1answer
616 views

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 ...
1
vote
1answer
301 views

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 ...
1
vote
1answer
118 views

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 ...
1
vote
0answers
103 views

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 %{...
1
vote
1answer
1k views

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:...
1
vote
1answer
787 views

htaccess file to perform specific rules to different domains [duplicate]

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 ...
1
vote
1answer
408 views

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 ...
3
votes
1answer
167 views

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 ...
1
vote
0answers
76 views

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.%{...
0
votes
1answer
61 views

apache2 append www to https url

I have an apache2 webserver in AWS using bitnami. In my bitnami.conf file I need to rewrite all URLs to https://www.example.com I am able to redirect the following correctly mydomain.com http://...
0
votes
2answers
374 views

Why doesn't this .htaccess file redirect properly?

I have a web application with multiple pages. The .htaccess file redirects everything after the domain-name.com/ to my index.php file, which processes the input and renders the appropriate page. ...
0
votes
1answer
706 views

Rewrite cond for domain and www.domain letsencrypt

I have this virtualhost in /etc/apache2/sites-available/cv.conf <VirtualHost *:80> ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/cv/web <Directory ...
1
vote
2answers
603 views

Unsure what this .htaccess set of rules is doing

I've inherited a web application, and in it is the following set of .htaccess rules. It appears to me that they do nothing. Can someone explain what they're doing? To me, it looks like they're ...
1
vote
0answers
54 views

Referrer Spam from Encoded URLs

I'm trying to prevent referrer spam to a number of websites I run. Then I encountered a lot of lines like this in the log files. \xd1\x81\xd1\x82\xd1\x80\xd0\xbe\xd0\xb9\xd0\xba\xd0\xb0.kz I'm ...
0
votes
1answer
110 views

Add www to domain but not for a specific domain

I've the following code in my .htaccess file: RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] The code above is for adding www to the domain if it does not ...
3
votes
1answer
975 views

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 ...
1
vote
1answer
2k views

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 ...
2
votes
2answers
185 views

.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 ...
1
vote
1answer
131 views

Combining more then 1 Apache rewriterule: virtualhost domain redirect and inputfile redirection

I got stuck on using Apache's RewriteCond and RewriteRule conditions. I usually don't use them a lot and mostly the documentation provides me enough information to produce a solution by my self. This ...
1
vote
1answer
671 views

htaccess rewrite cond for rewriting 404 errors on url's excluded

I have this problem with my .htaccess file. Google has some URL's indexed I don't want (404 Error) in Webmaster Tools. I need to rewrite URL's that include --, /- or an ending in - like so: replace ...
0
votes
0answers
500 views

nginx display image404.php if image not found

Having to move a .httacess into nginx version: nginx/1.11.2, most of it with success but one rewrite is still troubling me. ##Return default placeholder image when image file on server not found ...
1
vote
2answers
3k views

to set RequestHeader in apache httpd server is not working

I have a requirement, where I need to set the RequestHeader with a value retrieved from the querystring of the URI. Approach adopted is to write the RewriteCond and ReWriteRule where the condition ...
0
votes
1answer
81 views

apache2 rewrite rule: delete any path from URL

I'm going crazy with a Rewrite Rule on Apache. Basically what I want to achieve is to rewrite any url like: http[s]://www.example.com/something to https://www.example.com I have a VHost on apache ...
0
votes
1answer
891 views

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

I have hosted multiple websites on my server all sharing the same code base having one htaccess. I need something like this. if (domainname != example.com) redirect to example.com if there any ...
1
vote
1answer
35 views

Having issues with my websites htaccess

I recently uploaded a PHP theme on my server. It's working fine on any other sections except my home page. For example, when accessing www.mywebsite.com/anything the theme is working but when on ...
0
votes
0answers
367 views

Case-insensitive fallback/redirect

I'm using some default images to show users the type of document that is used. e.g. this image to show there is a .png file In the /osr/icons/mime/ folder I have images for a multitude of files, e.g....
-2
votes
1answer
142 views

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

I am new to system admin side. I need to create one subdomain with capital letters. e.g our main URL will be test.com and one of our sub-domain will be SS then instead of writing ss.test.com I want ...
0
votes
1answer
270 views

how to give subnets for IP addresses in rewrite condition?

I want to give subnet for various IPs while writing rewritecond. So how should i give the subnet mask in the below rule. the IP is 218.104.51.160/29 RewriteCond %{HTTP:X-Forwarded-For} !^IP ...
2
votes
1answer
100 views

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/([^/...
1
vote
0answers
16 views

How to provide read access to a folder and its files via htaccess

This is probably trivially easy but after RTFM'ing and trying several things I seem to be a bit stuck... The current version "appears" to let me access the directory BUT NOT the files via the browser....
0
votes
1answer
95 views

How do I prevent RewriteRules conflicting

I have three RewriteRules I am trying to implement but I cannot get all 3 to work together: RewriteRule ^products$ http://%{SERVER_NAME}/en_ca/products [L,R=301] RewriteRule ^products/(.*)$ http://%{...
0
votes
1answer
21 views

.htaccess not behaving as desired

Eventhough I'm new at htaccess, I've been learning a lot in the past few days, but I'm stuck on a certain part that resulted in the website not behaving as desired. Here is the part of the code where ...
-2
votes
1answer
231 views

apache: prepend a string literal to a TestString in a RewriteCond for mod_rewrite [duplicate]

So I can clearly do this: RewriteCond %{REQUEST_FILENAME}\.php -f But I cannot do this: RewriteCond some_directory/%{REQUEST_FILENAME}\.php -f Furthermore, this also fails: RewriteCond prefix%{...
0
votes
1answer
365 views

Have Apache serve static content instead of forwarding it to Plone (++resource++)

I have a Plone-based site, running behind Apache 2.4, which could perform a little better. One idea is to have Apache serve the static parts of the contents, preventing them from being rewritten for ...
1
vote
1answer
255 views

Nginx try_files instead of IFs to accomplish conditional logic

I'm trying to create Nginx vhost configs that will include the equivalent of the Apache htaccess rewrite rules for OpenCart. Here is the orignal: RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f ...
0
votes
2answers
536 views

how to write RewriteCond for a url with subdomain

I am trying to ban some bots by writing a RewriteCond rule in htaccess file. Is the following ruleset correct if I add the following: ## block traffic from particular referrers RewriteEngine On ...
0
votes
2answers
1k views

How to rewrite URI from root if file doesn't exists in folder?

I have a static folder which is not in my document root. I would like to redirect all the files that are not present in document root, but are present in the static folder. (So if the same file is in ...
1
vote
1answer
54 views

URL rewriting a specific directory

I want to rewrite the URL when receiving a request that is not a file and either for directory subdir or not a directory at all. E.g. (!file) && ( (subdir ) | ( !directory ) ) Here's my ....
1
vote
0answers
147 views

Apache rewrite rule for multiple named virtual hosts with a 'catch all' rule

I have a redirect apache server that I setup for about 30 domains. I want to have all requests get redirected to the main server except for 1 domain. Basically any domain coming to this server gets ...
0
votes
1answer
608 views

apache rewrite rules, non-www, https

I have two applications on the same server and use apache rewrite rules to redirect: www requests to non www http reuests to https Everything works ok, except one case: request www.test2.test.eu is ...
0
votes
1answer
846 views

Converting htaccess rewritecond to nginx

I'm very new to nginx, but have previous experience with apache redirects. I converting a subdomain to a subfolder and need some help with getting my rewrite rules correct for my switch. The subdomain ...
0
votes
1answer
260 views

Route request to Tomcat only if file doesn't exist on disk

I have Apache in front of my Tomcat installation as a reverse proxy. Most URLs are routed to Tomcat by a JkMount directive in Apache. For one URL pattern I'd like Apache to route requests to the ...
0
votes
1answer
458 views

Nginx and complex URI rewrites

I'm having problem with getting logic behind Nginx rewrites. Are they supposed to be in server or location directive? I need to rewrite one long and scary URL to another. Is there anyone who can ...
0
votes
1answer
78 views

apache rewrite rules for multimple domains | https://www

I have two applications configured on one apache (eg. example.com and test.net). Rewrite rules for those apps are the same (so in config file for domain example.com I've got this rules, and the same ...