Questions tagged [rewritecond]

132 questions
0
votes
1 answer

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 have the www. But I have a domain like:…
Igor
  • 135
  • 7
0
votes
0 answers

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 RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}…
Joakim
  • 39
  • 2
  • 7
0
votes
1 answer

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 like the following: ServerName…
cloud81
  • 163
  • 1
  • 2
  • 8
0
votes
0 answers

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. avi.png, html.png, jpg.png, ... So I simply…
Pit
  • 121
  • 5
0
votes
1 answer

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 RewriteRule ^ - [F,L]
Ankit
  • 11
0
votes
1 answer

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://%{SERVER_NAME}/en_ca/$1 [L,R=301] RewriteRule…
Rob Fyffe
  • 103
  • 1
0
votes
1 answer

.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 I have my delima: Options +FollowSymLinks…
elrayyes
  • 3
  • 2
0
votes
1 answer

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 the Plone process, as is commonly…
Tobias
  • 165
  • 1
  • 9
0
votes
2 answers

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 RewriteCond %{HTTP_REFERER}…
developer
  • 555
  • 2
  • 8
  • 16
0
votes
1 answer

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 redirect to https://www.test1.com content How can…
gaspar
  • 133
  • 1
  • 10
0
votes
1 answer

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 is hosted on an apache server, with the new…
0
votes
1 answer

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 Tomcat worker only if a static asset isn't found on…
spiffytech
  • 1,063
  • 2
  • 11
  • 17
0
votes
1 answer

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 help or at least show me resources to get this done?…
Chris
  • 1
0
votes
1 answer

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 rules in conf file for test.net…
gaspar
  • 133
  • 1
  • 10
0
votes
3 answers

How to remove hypen (-) using nginx rewrite rule?

I am using this rewrite rule to redirect example.com/a-b-c?id=learn-more ----> http://example.com/abc?id=learnmore rewrite ^/a-b-c?id=learn-More http://example.com/abc?id=learnMore permanent But its not working !! It is redirecting to…
user3382916
  • 11
  • 1
  • 3
1 2 3
8 9