URL rewriting module for Apache web servers

learn more… | top users | synonyms (1)

145
votes
5answers
23k views

Redirect, Change URLs or Redirect HTTP to HTTPS in Apache - Everything You Ever Wanted How 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 ...
0
votes
5answers
5k views

Configuring Apache, Tomcat, mod_jk and mod_rewrite to serve up tomcat from top-level

I'm trying to set up my java app as the main component of a new site. I have some static resources I'd like served by Apache, so I setup Apache and Mod_jk, with the following rules, JkMount ...
4
votes
1answer
1k views

Forcing SSL in Apache without hard-coding the hostname

I think that I have this sorted (thanks mainly to the question How to redirect non-www to www without hardcoding using .htaccess?), but I still don't entirely understand a couple of things. I would ...
30
votes
4answers
81k views

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: <VirtualHost ...
4
votes
5answers
8k views

apache server-status not found. check if mod_status is enabled

I've enabled the apache_ plugins on a munin node: ln -sv /usr/share/munin/plugins/apache_* /etc/munin/plugins/ After restarting the node with service munin-node restart here are the errors I'm ...
3
votes
1answer
1k views

Understanding apache 2.4 mod_proxy_fcgi and RewriteRules in htaccess

We've recently switched one of our web servers to apache 2.4 and running PHP via php-fpm and mod_proxy_fcgi. Most everything works quite well, but there is one problem that I don't understand yet. One ...
2
votes
1answer
3k views

How to use Apache to proxy from subfolder to other server

Given the following url: domain.com/wiki/ I'd like apache to redirect all requests below that (so domain.com/wiki/*) to otherdomain.com:8080/. But the trick is I want the user to always see ...
2
votes
2answers
1k views

Mod ReWrite Catch-All Subdomain

Basically I want *.domain.com to pull up domain.com/*/ (not redirect). I went into the subdomains section of cPanel and set a wildcard for this domain. It appears to be resolving correctly, ie ...
0
votes
1answer
6k views

Custom Apache ErrorDocument with proxy balancer & RewriteEngine

I'm running into various problems trying to add custom ErrorDocuments to my server. I'm using proxy balancer to share the load between two instances of Zope and some simple rewrite rules to map my ...
7
votes
4answers
4k views

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, ...
3
votes
2answers
248 views

Is there an Elegant solution to rewrite long image?query-urls into cachable_nice_urls, using only apache htaccess?

this is a pain in the ass-problem! Whicever genius solves this riddle will receive paypal donation to eat diner for two. Now lets get started. Given: most proxies, do not cache resources with a "?" in ...
1
vote
1answer
247 views

Apache Dynamic Virtual Host with SSL [duplicate]

I have the following in my httpd.conf file NameVirtualHost *:80 <IfModule mod_vhost_alias.c> <VirtualHost *:80> ServerAlias * UseCanonicalName Off LogFormat "%V %h %l %u %t ...
1
vote
1answer
172 views

Why servers error log states lots of file doesn't exist, but files are accessible and website works well

we migrated our website onto VPS server (CentOS 5.6 + Plesk 9.5), everything works nice, but one strange thing that i noticed in Plesk, is error_log file, most of the time it filled up with hundreds ...
1
vote
2answers
3k views

what is lighttpd equivalent of RewriteCond %{REQUEST_FILENAME} !-f?

RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule !\.(js|ico|gif|jpg|png|css)$ /index.php This is Zend htaccess, I can't seem to find a lighttpd equivalent of ...
0
votes
2answers
13k views

Apache Virtual Host with Alias

I have a virtual host running on my local copy of Apache. It has an alias. <VirtualHost 127.0.0.1> ServerName oliverash.me.dev DocumentRoot "/usr/docs/oliverash.me/public" ...
5
votes
2answers
6k views

How can I redirect any ServerAlias to the respective ServerName?

I want to 301 redirect all example.org to www.example.org. The following example is doing just that, but it's got a lot of noise to it and is thus hard to maintain and error prone: <VirtualHost ...
2
votes
4answers
2k views

Apache rewrite rules and DNS settings for HTTPS sites

For a web application located at: https://www.domain.com/ With an SSL certificate issued to "www.domain.com", What is are the proper rewrite rules, DNS settings, or combination of both which makes ...
2
votes
2answers
1k views

Can I make Apache drop a connection when matching a URL?

Using mod_rewrite I can construct a rule to respond with a clean error code (e.g. 404 not found, 410 gone, or 403 unauthorised) when a page is requested that I don't want to serve. But frequently I ...
1
vote
1answer
414 views

Make post title as a slug in url by mod rewrite

I have previously posted a question but I am not satisfied with the answers. I have a url, for example http://example.com/details.php?a=100&b=101&slug=power-programming-in-php I want to ...
0
votes
1answer
226 views

htaccess rewrite rule

Well i have this code into my .htaccess file Options +FollowSymlinks RewriteEngine on AddDefaultCharset UTF-8 RewriteCond %{THE_REQUEST} ^[A-Z]+\ (.+)\.php [NC] RewriteCond ...
0
votes
1answer
639 views

Redirect subdomain virtual host subdomains to path

I used Apache's virtual host for a ton of subdomains for greptweet.com, where each twitter username is a subdomain, like <username>.greptweet.com. Problem is ... subdomains can't have ...
0
votes
2answers
899 views

Apache mod_rewrite not working

I installed Apache through its windows installer and then PHP and MySQL too. Wordpress is working fine on this setup so it means the basic setup required is working fine. But somehow mod_rewriting is ...
7
votes
1answer
3k views

max length of url 257 characters for mod_rewrite?

My url scheme is /foo/var1-var2-var3.../bar I am using these mod_rewrite rules: RewriteBase /foo/ RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d ...
4
votes
4answers
1k views

Preventing vulnerability scripts from scanning apache server

Quick question for you all - fairly frequently in my httpd logs I see things like this: 66.11.122.194 - - [29/Jan/2010:11:06:44 +0000] "GET HTTP/1.1 HTTP/1.1" 400 418 "-" "Toata dragostea mea pentru ...
1
vote
1answer
488 views

apache mod_rewrite fails when file by same name exists

The complete .htaccessfile RewriteEngine on RewriteBase / RewriteRule ^([a-z0-9_\-]+)/([a-z0-9_\-]+)/(index\.php)?$ /main.php?type=$1&action=$2 [NC,QSA,L] so, www.server.com/users/new/ ...
6
votes
2answers
6k views

How to port Apache rewrite rules to cherokee?

I'm pretty new to cherokee, it's great and pretty straight forward except URL Rewrites. Is there a straight forward guide to it? Let me know. Also how would I port this: RewriteEngine on RewriteCond ...
5
votes
1answer
107 views

How to minimise effect of mischievous, persistent POST requests

For a few months now one of our shared hosting servers has been persistently and constantly hammered by "POST /" requests from what must be hundreds of thousands of individual IPs. On a number of ...
4
votes
1answer
474 views

Dynamic subdomains, mod_python and trac

I'm going to be running multiple subdomains, eventually too many to be able to each have their own config files. I have the vhosts working how I want them so each subdomain has their own folder eg ...
1
vote
2answers
119 views

redirect not-active subdomains

EDIT: How can you redirect all non-active subdomains to 'www'? Here I try to redirect all subdomains not listed to 'www'.. I can't make it work properly because %1 and %2 doesn't return anything.. ...
1
vote
1answer
498 views

Apache request contains full physical path when trailing slash omitted

My original goal was to rewrite requests to http://server.com/node/XXXXX to http://server.com/node/index.cgi?XXXXX. node really is a physical directory containing index.cgi, located directly under the ...
1
vote
1answer
200 views

Redirecting a specific URL to a different vhost in apache

I have two versions of a very small ruby-on-rails apps running on my web server. One is served externally (production) and one is served only on an intranet URL (staging). So I have two Virtual ...
1
vote
3answers
683 views

broken apache .htaccess (mod_rewrite)

Hey there, I'm running into an apache mod_rewrite configuration issue on one of our machines. Has anyone encountered / overcome anyone of these issues. URL1 ( http://www.uppereast.com ) is not ...
0
votes
3answers
137 views

How can I test for a URLs existeance before redirecting to it?

I am using Apache's mod_rewrite to redirect mobile users to my mobile site based on their http_user_agent. However not all pages have a mobile equivalent. Also mobile pages end in .html and "full" ...
0
votes
1answer
224 views

Compact Redirects in Apache/htaccess. How? [An Elegant Coding Question]

when setting my redirects in htaccess, i have trouble setting/combining various domains when they all go to the same homepage. I can do them separate, but that isn't neat/elegant. How to rewrite the ...
0
votes
1answer
200 views

url rewrite to make generated thumnails cache like static, a syntax question

this is a pain in the ass-problem!! Given: most proxies, do not cache resources with a "?" in their URL even if a Cache-control: public header is present in the response. To enable proxy caching for ...
9
votes
2answers
5k views

best way to debug nginx 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 ...
3
votes
1answer
57 views

Multiple rule Apache rewrite

I am trying to set up a hierarchy five levels deep with mod_rewrite. This is what I have put together at this point. It works for the last two levels (the first and second rule) but not after that. ...
3
votes
2answers
8k views

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

How can I use apache to redirect users (based on user_agent and using mod_rewrite) to my mobile site only if a mobile pages exists.

I want to detect mobile users based on their user_agent. If a user is browsing the full version of the site and they have a certain user_agent, I want to redirect them (using mod_rewrite) to the ...
2
votes
2answers
3k views

Apache Rewrite or Proxy to internal server

First off, this is my first go at apache, so please forgive my beginingingismness :) My basic setup is as such: mysub.domain.com gets sent to my static IP via a CNAME entry at godaddy's DNS manager. ...
2
votes
1answer
495 views

Configure apache rewrite to offer home page at root, when rest of site is at subdir?

For legacy reasons, I have a wordpress site that primarily lives at a subdirectory: http://www.zmxmusic.com/site . However, it also serves the home page at http://www.zmxmusic.com . I don't have ...
2
votes
1answer
1k views

How to set the VirtualDocumentRoot based on the files within

I'm trying to set up Apache to use the VirtualDocumentRoot directive but my sites aren't all exactly the same. Most of the sites have a drupal folder which should be the root but there are a few ...
2
votes
2answers
730 views

Order of mod_rewrite rules in .htaccess not being followed

We're trying to enforce HTTPS on certain URLs and HTTP on others. We are also rewriting URLs so all requests go through our index.php. Here is our .htaccess file. # enable mod_rewrite RewriteEngine ...
2
votes
1answer
1k views

mod_rewrite adding documentroot to url

The following rewrite redirects http://example.com/ to http://example.com/www/www.example.com/public%5Fhtml instead of http://www.example.com/. /www/www.example.com/public_html is the DocumentRoot. # ...
1
vote
4answers
332 views

HTTPS / HTTP mod_rewrite rules, strange interaction with subsequent CMS index.php rewrite

With the below rewrites in htaccess, as expected, this HTTPS request is not rewritten: https://example.com/system/anything is not re-written to http://example.com/system/anything But, ...
1
vote
1answer
85 views

Can mod_rewrite distinguish between 'user' request and internal redirect?

Simple question really. After an internal redirect, the original 'context' is gone. I'd like to know if there is a variable or flag that allows me to check against the original request instead of the ...
1
vote
0answers
159 views

Apache: Setting up a reverse proxy configuration with SSL with url rewriting

There is a host: secure.foo.com that exposes a webservice using https I want to create a reverse proxy using Apache that maps a local http port on a server internal.bar.com to the https service ...
1
vote
2answers
142 views

Ubuntu Server: Apache2 seems to attach .php to URI

I'm using the php library tonic for web services. My resource is as example at base-uri/myResource Now if a file myResource.php exists in that directory, the url mod_rewrite gets to see is ...
1
vote
1answer
905 views

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

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

use a domain on one server to load an application on another server

I have an application sitting on a ubuntu operating system located on one server. It responds to an ip address with domain, let's say, abc.com. Now there's another server that responds to the domain, ...