Questions tagged [mod-rewrite]

URL rewriting module for Apache web servers

For an introduction and examples of using mod_rewrite, read over the comprehensive article,
"Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask"

2176 questions
281
votes
5 answers

Redirect, Change URLs or Redirect HTTP to HTTPS in Apache - Everything You Ever Wanted to Know About mod_rewrite Rules but Were Afraid to Ask

This is a Canonical Question about Apache's mod_rewrite. Changing a request URL or redirecting users to a different URL than the one they originally requested is done using mod_rewrite. This includes such things as: Changing HTTP to HTTPS (or the…
Kyle Brandt
  • 82,107
  • 71
  • 302
  • 444
70
votes
4 answers

Redirect URL within Apache VirtualHost?

I have a dedicated server with Apache, on which I've set up some VirtualHosts. I've set up one to handle the www domain as well as the non-www domain. My VH .conf file for the www: DocumentRoot /var/www/site ServerName…
DisgruntledGoat
  • 2,569
  • 4
  • 26
  • 34
57
votes
4 answers

best way to debug nginx rewrite rules in config file?

I have a bunch of rewrite rules that I have to port from apache to nginx. It's a rather painful process because I'm not able to see if my rewrite rules and "if" conditions are working as I want them to. Apache did have debugging for its rewrite…
Jiho Kang
  • 967
  • 2
  • 9
  • 8
36
votes
3 answers

How to Exclude an URL for Apache Mod_proxy?

We have two Apache server as front-end and 4 tomcat server as back-end configured using mod_proxy module as load balancer. Now, we want to exclude an single tomcat url from the mod_proxy load balancer. Is there any way or rule to exclude? Proxy…
Mughil
  • 1,869
  • 1
  • 18
  • 28
20
votes
3 answers

Suspicious .htaccess File

This was uploaded to one of my FTP folders. I'm not familiar with Apache, but still curious - can someone tell me what type of dastardly act this file is trying to commit? Thanks! RewriteEngine On RewriteCond %{HTTP_REFERER} .*google.*$…
ovinophile
  • 303
  • 1
  • 4
20
votes
9 answers

How to I test if mod_rewrite is enabled?

I'm setting up an environment for wordpress on apache2, on a fresh install of ubuntu 12.04. In order to get friendly URLS working, I'm trying to set up mod_rewrite. I followed some instructions I found on the net, and used a2enmod. Now. after…
user124130
  • 201
  • 1
  • 2
  • 3
17
votes
3 answers

Returning "200 OK" in Apache on HTTP OPTIONS requests

I'm attempting to implement cross-domain HTTP access control without touching any code. I've got my Apache(2) server returning the correct Access Control headers with this block: Header set Access-Control-Allow-Origin "*" Header…
Mark McDonald
  • 576
  • 1
  • 4
  • 12
16
votes
3 answers

apache2.4 mod_rewrite exclude specific alias directroy/uri

I have the following setup on one of my vhosts: ... ServerName cloud.domain.de ServerAdmin webmaster@domain.de ServerSignature Off Alias "/.well-known/acme-challenge"…
FleBeling
  • 163
  • 1
  • 1
  • 5
16
votes
2 answers

Apache URL rewriting in reverse proxy

I'm deploying Apache in front of a Karaf-hosted application (Apache and Karaf are on separate servers). I want Apache to operate as a reverse proxy and also to hide part of the URL. The URL to get the log-in page of the application directly from…
15
votes
4 answers

Controlling Nginx proxy target using a cookie?

I'm trying to convert a reverse proxy using an interesting Apache mod_rewrite setup to use Nginx instead (due to external concerns we are moving from Apache to Nginx, and most everything works fine except this part). My original setup was to read an…
Guss
  • 2,520
  • 5
  • 32
  • 55
13
votes
2 answers

Why is enabling the rewrite log in .htaccess not working?

I want to enable rewrite logging so that I can debug a rewrite rule but adding the RewriteLog directives is causing a 500 error. Version information: Ubuntu 14.04 Server version: Apache/2.4.12 (Ubuntu) Server built: Feb 4 2015…
codecowboy
  • 1,287
  • 5
  • 17
  • 31
13
votes
1 answer

Apache mod_rewrite double encodes query string on redirect

We've encountered a strange issue (a bug, perhaps?) with Apache mod_rewrite's behavior when passing through query strings. To reproduce, we've set up a clean Ubuntu (oneiric) install with the default Apache configuration. We have enabled…
Erik Hesselink
  • 231
  • 2
  • 7
13
votes
2 answers

Apache rewrite multiple conditions

I have a website that's migrated from an old domain name (e.g. olddomain.com) to a new domain name (e.g. newdomain.com). For SEO reasons, I need to rewrite all website traffic to the primary new domain name (e.g. www.newdomain.com). Unfortunately,…
gurun8
  • 335
  • 1
  • 4
  • 11
13
votes
4 answers

Rewritten URLs with parameter length > 255 don't work

I'm using mod_rewrite to rewrite URLs like this: http://example.com/1,2,3,4/foo/ By doing this in .htaccess: RewriteEngine On RewriteRule ^([\d,]+)/foo/$ /foo.php?id=$1 [L,QSA] It works fine, except for when "1,2,3,4" turns into a string longer…
philfreo
  • 987
  • 2
  • 9
  • 22
13
votes
3 answers

How can I enable mod_rewrite in apache on Ubuntu?

How do you enable mod_rewrite with Apache in Ubuntu 10.04? I tried copying rewrite.load from /etc/apache2/mods-available to etc/apache2/mods-enabled but that didn't work.
Nathan Osman
  • 2,705
  • 7
  • 31
  • 46
1
2 3
99 100