mod-rewrite

Excluding a directory with ISAPI-Rewrite

I am trying to exclude a directory with ISAPI-Rewrite (note: this is a windows/iis port of mod-rewrite). The directory I want to exclude is "api" when it is at the root of the site. Here is my rule: RewriteRule ^(/api/)(.+)$ $1$2 [NC, L] A request would look something like this: /api/v2/users?usernames=scottw Unfortunately, the quer...

Map Domain Alias to Virtual Folder in IIS6

How could I go about mapping a domain alias, e.g. domainAlias.co.za, to a virtual folder under, e.g. mainDomain.co.za, so that all requests to domainAlias.co.za actually get served by mainDomain.co.za/domainAlias ? ...

Can mod_rewrite convert any number of parameters with any names?

I'm a total n00b at mod_rewrite and what I'm trying to do sounds simple: instead of having domain.com/script.php?a=1&b=2&c=3 I would like to have: domain.com/script|a:1;b:2;c:3 The problem is that my script takes a large number of parameters in a variety of combinations, and order is unimportant, so coding each one in the expression a...

URL rewrite using mod_rewrite in .htaccess

Hi, I am trying to rewrite the URL using the mod_rewrite apache module. I am trying to use it as below : Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^wants/testing.htm wants.php?wantid=$1 [L] I have created a .htaccess file in the directory from where the files are accessed. The mod_rewrite is also enabled. W...

Can mod_rewrite preserve a double slash?

Im just learning mod_rewrite and regex stuff, and what I'm trying to do is pass variables of any name, with any number of variables and values, into a script and have them forwarded to a different script. here is what I have so far: RewriteEngine on RewriteRule ^script\$(.*[\])? anotherscript?ip=%{REMOTE_ADDR}&$1 [L] That all seems ...

mod_rewrite URL info required

I am new to this mod_rewrite. I have been successfully able to rewrite the URL something like this: "http://mydomain.com/products/12" to "http://mydomain.com/products.php?prodId=12" But when I give http://mydomain.com/products/12 in the address bar... the css and js files are not loaded. But when I access "http://mydomain.com/products...

.htaccess mod_rewrite playing with variables

I want to have my site urls look like http://example.com/place/info?var=info&morevars=ifneeded Place and info are also variables but they have a fixed name, the ones after would vary. EDIT This is the url I am trying to rewrite http://example.com/test.php?place=test&action=info&var=info&morevars=ifneeded This is wha...

Rewrite for all URLs

I would like to rewrite something like: http//www.example.com/index.php?var1=val1&var2=val2&var3=val3 Into http://www.example.com/var1/val1/var2/val2/var3/val3/ I'm looking for a solution to work on an arbitrary number of variables. Can it be done? ...

mod_rewrite issue

Hey all, I have the following rule: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !=/favicon.ico RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] and my url is as follows: http://www.mydomain.com/189-9544737-0616922?%5Fencoding=UTF8&node=10 On myphp.php var_dump($_GET): array(3)...

how to use mod rewrite

I have transferred my website from old server to shared server. All my code is in "lfdata/main/com" under "public_html" on the shared server. The clean URL would look like follows: http://ip-address/~name/how and the rewritten URL should be: http://ip-address/~name/lfdata/main/com/how.php So can anyone suggest a rewrite rule for cr...

Reading rewrited (mod_rewrite) files from php

Assuming you have only the URL to a file (hosted on the same server as the app) that has been rewritten via mod_rewrite rules. How would you read the contents of that file with PHP without having direct access to a .htaccess file or the rewrite rules used to building the original URL? I'm trying to extract all the script tags that have...

.htaccess/mod_rewrite

Hi, My code is in lf/main/com folder. I have displayed categories on my index page. Ex. childcare, housecleaning.. I need if I click on childcare the clear URL will be childcare.example.com or childcare.ipaddress/~name/ The actually/processed URL will be http://ipaddress/~name/search.php?cat=childcare Thanks, S ...

How to get mod-rewrites and php 301 redirects?

I was hoping someone could also guide me on setting a redirect on a php site pcs4cheap.ca ....I tried to do mod re-writes through the .htaccess, works fine but prevents any othe login or admin page to open ! Any other way I could achieve this would be much appreciated =) ...

Redirecting Apache by Geo/Country IP

Do any of you folks do redirection by IP (within Apache) for people coming to your website from different countries? What do ye use? mod_geoip and/or a whole pile of mod_rewrite rules? Is mod_geoip reliable/well-performing/accurate? ...

PHP include() affected by mod_rewrite

Hi, I have inherited a number of grossly coded PHP files, whose output I need to alter programmatically. To achieve this, I chose to run them through another PHP file, rewriter.php, which looks approximately like this: <?php if(!preg_match('/^([a-zA-Z0-9\-_]*)$/', $_GET['page'])) die('Incorrect page supplied.'); ob_start('changeOutp...

.htaccess/mod_rewrite

Hi, Actually I want to run ~name/how instead of ~name/how.php. I have made following changes in .htaccess: # If the requested URI does not contain a period in the final path-part RewriteCond %{REQUEST_URI} !(.[^./]+)$ # and if it does not exist as a directory RewriteCond %{REQUEST_fileNAME} !-d # and if it does not exist as a file Rew...

Absolute and Relative problem in .htaccess (mod_rewrite)

Hi I am new to .htaccess and mod_rewrite. I am using the following Rewrite rules : RewriteRule ^wants/([0-9]+)$ /wantlist.php?wantid=$1 RewriteRule ^dashboard$ /dashboard.php I am able to successfully redirect both the cases. But in order to do this, I had to change the css, js and other paths to absolute paths without which the ...

Using mod rewrite to change URL with username variable

How do I change the following client-side URL domain.com/profile/jung domain.com/jung (preferable) to a server-side URL of domain.com/profile.php?user_id=100 with the username in a php variable? I know I need to edit my htaccess file with a RewriteCond and RewriteRule but it's still not clear to me... How does Twitter manage thei...

Rails page caching with Apache and capistrano

The following post explains about the page caching in rails with Nginx. http://blog.hasmanythrough.com/2008/1/30/segregated-page-cache-storage I like to implement this solution with my app but on Apache. So, the main block/route is if (-f $request_filename) { break; } if (-f /cache$request_filename) { rewrite (.*...

How do I rewrite URLs that have GET variables in them?

I have a site that makes use of GET variables to determine what to display. @session_start(); @extract($_GET); @extract($_POST); . . . if (!$menu) { include("home.php"); } if ($menu=='buy') { include("buy.php"); } if ($menu=='invalidbuy') { include("invalidbuy.php"); } if ($menu=='buydone') { include("buydone.php"); } . . . I think I ...