mod-rewrite

Using Apache for load balancing routing

My application has two internal section: Upload section url: %URI%/upload/%action% Login section url: %URL%/Login/%action% The code for Login section is located on one server 5.123.12.1, whereas the code for Upload is located on another server 5.123.12.2. After the server routing, there will be further routing pertaining to the requ...

Mod Rewrite problem

I have a problem that I cannot wrap my head around. I'm using Apache and PHP I need to get: http://localhost.com/cat_ap.php?nid=5964 from http://localhost.com/cat_ap~nid~5964.htm How do I go about changing that around? I have done more simple mod rewrites but this is slightly more complicated. Can anyone give me a leg up or point...

More Mod_rewrite problems

Ok, have a client that has existing links coming in from searchmarketing. I am in process of migrating the program from Cold Fusion to PHP. RewriteEngine on RewriteRule ^cat_ap~([^~]+)~(.*)\.htm$ /urban/cat_ap.php?$1=$2 [R] Currently I have a URL structure: http://www.test.com/urban/cat_ap~nid~5964.htm which the above rewrite rule...

site 5x faster via mod_rewrite, but CSS images are broken

I am using .htaccess to accelerate a site with the following redirects: request for http://example.com/images/name.jpg routed to http://i.example.com/name.jpg request for http://example.com/css/name.css routed to http://c.example.com/name.css From listening to the Stack Overflow podcast, I learned that this could make a site fa...

Mod Rewrite, pass parameters from URL1 to URL2

I'm trying to rewrite the following URL test.php?par1=foo&par2=bar Into... newtest.php?hidden_par=blah&par1=foo&par2=bar I have this rule, that does not work: RewriteRule ^test.php\??(.*?)$ newtest.php?hiden_par=blah&$1 [L] Could this be done using RewriteCond or something else? (say, could this be done ?), thanks in advance. ...

mod_rewrite rule to check for maintenance page except for certain subdomains

I have configured Apache to look for the presence of a maintenance page and redirect to that page if it is present: RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f RewriteCond %{SCRIPT_FILENAME} !maintenance. RewriteRule ^.*$ /system/maintenance.html [L] This is fairly standard practice for deploying Ruby on Rails apps. What ...

mod_rewrite: Convert 'Folders' in URL Into Query Parameters

I want to be able to take a URL like: http://www.example.com/valOne/valTwo/valThree/valFour/valFive and convert it to: http://www.example.com/index.php?one=valOne&two=valTwo&three=valThree&four=valFour&five=valFive I really only need a few query parameters for my application so the Regular Expression could have thes...

.htaccess redirect if file doesn't exist

So here's what I'm trying to do. I have a simple framework and I am using mod rewrite to rewrite the urls so that they point to the correct files. I have a process folder which sits inside the web folder (the web folder is where all the actual website files like images, css, etc are). This works great but what I am trying to do now is t...

php mod rewrite

...

What's wrong with my RewriteRule?

My .htaccess file currently looks like this AddType x-mapp-php5 .php Options +FollowSymLinks Options +Indexes RewriteEngine On RewriteBase / RewriteRule ^account$ /account/orders.php [L] When I go to http://mywebsite.com/account it properly shows the page at http://mywebsite.com/account/orders.php. But when I change the RewriteRule t...

How many RewriteRules can you have in .htaccess without trouble?

Simple question. Is there a limit as to how many RewriteRules I can have in my .htaccess or can I put a zillion of them in there without Apache going all funky on me? Is there a relative limit where the server simply dives because there are to many rules to iterate through? Thanks! ...

Mod_rewrite for IIS

Is there anything similar to mod_rewrite for IIS 6/7? I want to be able to point several domains (I'm guessing using CNAMEs) to one domain "abc.com", and then do a redirect to "abc.com/start.html" once the browser hits that domain. ...

htaccess conditional rewriterule problem

My rewriterule with a condition is working fine as below: http://www.sitename.com/index.php?n=text redirects to http://www.sitename.com/pages/text and the page renders properly, however, there is a problem that with the redirected URL the arguments are also added to the URL. So actually in address bar it looks like- http://www.sitena...

.htaccess !-f rule not working

I have been using simple mod_rewrite rules for my CMS for years and am now making a new version, I am seeing the rewriteCond not making sense- I have the standard "if is not a file" but I still see the rewriterules being evaluated even though they're not supposed to. My rewrite code: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQ...

RewriteMap activation

How to activate RewriteMap in apache ? I tried to run rewritemap in httpd config when I restart apache, it says that "RewriteMap not allowed here" i tried to google and go to apache but couldn't find a way to activate it. anyone know? thanks. :) ...

How does RewriteBase work in .htaccess

I have seen this in a few .htaccess examples RewriteBase / It appears to be somewhat similiar in functionality to the <base href=""> of HTML. I believe it will automaticlally prepend it's value to the begining of RewriteRule statements (possibly ones without a leading slash)? I could not get it to work properly. I think it's use co...

Simple mod rewrite question

Here is my current .htaccess file: RewriteRule ^$ index.html [QSA] RewriteRule ^([^.]+)$ $1.html [QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] As you can see, requests to http://domain.com go to http://domain.com/index.html. I want to change this so that they go to http://domain.com/foo, please no...

Why would this .htaccess skip over my RewriteBase ?

Here is the begining of my .htaccess # invoke rewrite engine RewriteEngine On RewriteBase /~new # force non domain.com to www.domain.com RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*) http://www.%{HTTP_HOST}/$1 [R=301,L,NC] everytime I request http://www.example.com/~new/whatever I am sent to htt...

How to point my home page traffic to my a Rails subdir

I have a rails controller handling requests to www.mydomain/foo, now I want all traffic to www.mydomain/ (the domain root or homepage) to go to www.mydomain/foo. I asked a similiar question about how to do this with ReWrite, and haven't gotten an answer yet, but I would be happy also solving it in the controller so I have opened up this...

Why would this .htaccess be stripping out containing folder?

This is from a .htaccess located under /~new/ # invoke rewrite engine RewriteEngine On # force domain.com to www.domain.com RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$0 [R=301,L,NC] When accessing http://domain.com/~new/hello, it is being rewritten to http://www.domain.com/hello The www. is bei...