rewrite

Translating Perl to Python

I found this Perl script while migrating my SQLite database to mysql I was wondering (since I don't know Perl) how could one rewrite this in Python? Bonus points for the shortest (code) answer :) edit: sorry I meant shortest code, not strictly shortest answer #! /usr/bin/perl while ($line = <>){ if (($line !~ /BEGIN TRANSACTION...

Apache rewrite engine, get subdomain and path after it

I have the basic code to rewrite a subdomain to another page. But how do I use this to get the path of the directory specified within it and pass it to my script as well as the subdomain itself? Current code RewriteCond %{HTTP_HOST} ^([^.]+)(\.example\.com)$ RewriteRule ^$ handle.php [L] I'd like to provide handle.php with the file p...

ASP.NET: change link to static asset dynamically

Hi all, We are building a internal static asset server. Each environment (dev, staging, prod) has its own asset server, and the asset is reference throughout the web application (html, aspx, ascx, css, javascript, etc...) To reference the correct asset server in the correct environment, one solution is to write a http module to interc...

ISAPI rewrite products

I need mod_rewrite functionality on an IIS .NET server. Is http://www.isapirewrite.com/ the best option? It seems to have the largest documentation/user base. I also see codeplex.com/IIRF , this is free but comments mention it has a different syntax from .htaccess? I am very unfamiliar with IS .NET and would like to mimic Apache .htacces...

Request Filtering/URL rewriting with IIS7 - not working

I cannot get the URL rewriting module to work on my local PC (vista x86) i set up a new rule using the 'user friendly url' template. a picture rather than 1000 words.... (the image contains 3 shots - creation, config and pattern test) http://www.sk8loc8.com/rewriteIssue.jpg so now that is setup if i request 'localhost/iisrewriteurl/...

Solved -> Just Installed ISAPI 3 -> httpd.ini / .htaccess not working!

trying a simple 1 to 1 redirect. I've tried this the ISAPI way and the Apache way, nothing seems to work. While I know this is very vague, I am very unfamiliar with this system. What steps would you recommend to troubleshoot? Problem Solved. For further discussion -> troubleshooting techniques ...

Git, rewriting history of master branch and associated tags

I've just had my first experience with rewriting the history of one of my repos (using git-filter-branch). The problem is that the repo had several tags, which after rewriting seem to be completely disconnected from the resulted history. I think this is due to the fact that the history associated with the tags hasn't been rewritten, so t...

URL Rewriting in asp.net loses stylesheet mappings.

i noticed that when using the URL re-writter out of iis 7.0 that the root url character "~" works correctly but when I re-write the url with the global.asax file, the files no longer map correctly. Why is this and what can I do to have all the files map properly when using global.asax to re-write urls? If URL.Contains("/myurl/") Then C...

OpenID and URL Rewriting

Hi, I am having a problem implementing OpenID on my ASP.NET site. I have got OpenID to work well when the return URL ends in .aspx, however whenever i try and return it to a rewriten URL (http://example.com/return/ is really http://example.com/return.aspx) it doesn't work. How can i set the rewrite rule so that OpenID will work. I am ...

When is it acceptable to rewrite someone else's code?

I largely work as my own dev shop, for a small organization in a large multinational. Almost every day, I find myself rewriting or upgrading my own code to a more informed solution. Obviously, this is fine, since I wrote the code I take no offense at rewriting it. However, I wonder if my reaction would be the same if someone else rewr...

progmatically rewritemap rules at runtime

Is it possible to add static rewritemaps rules progmatically for ASP.NET 3.5 I have:- <rewriteMaps> <rewriteMap name="My Name"> <add key="/Sales" value="/Test.aspx?id=10" /> <add key="/Sales-And-Marketing" value="/Test.aspx?id=10&amp;dog=cat" /> </rewriteMap> </rewriteMaps> but would like to add these progmatically ...

Help refactoring CSS

Okey, guys I have following code: #adminmenu li.hideshow-news, li.hideshow-users, li.hideshow-pages, li.hideshow-gallery, li.hideshow-references, li.hideshow-settings { display: none; font-size: 11px; background: #fff; padding: 3px; } I want to achieve (as I tried here) using only one line for diffrent classes on in div "adminmenu"....

.net Url rewriting for localization, issues with forms authentication and the loginUrl

I'm using a HttpModule to rewrite the urls on a multi-lingual site. In the HttpModule, I'm adding a handler for the BeginRequest event, and looking for the first part of the path which contains the culture name. For example, /fr-ca/index.aspx will be rewritten to /index.aspx and set the thread's culture and ui culture to 3084. This work...

Rewriting a system from scratch: what do you include in proposals?

Let's say I have an older system/framework that's showing its age a bit, but will soon be leveraged to do much more than it was first intended to do. It's a web app that didn't have a lot of common codebehind in it, so I've proposed that it will be less man-hour effort in the long run to rebuild it using more forward-looking code, with a...

rewrite a folder name using .htaccess

Hello everyone/ I am wondering wether it's possible to use .htaccess to rewrite a folder name. What I mean is this. Lets say I have a url like: www.site.com/folder1/page.php Now I want to rewrite the url to (for example) www.site.com/apple/page.php The folder1 is an existing folder on my webspace. important: the "apple" is not a...

Efficient way to realize permalinks in php

What is the most efficient way to realize php-driven permalinks? Basically I want to reduce the database accesses to a minimum. What is the best way to redirect to an id stored in the database? ...

Rewrite Route to map to default route

Hi! Because of the problems I experienced here: Zend_ Controller_ Router_Exception: “xyz” is not specified I want to have this route: ":module/:controller/:id" and map it onto this: ":module/:controller/:action/id/$id" Is there any possibility to do this with Zend Framework? I do not want to forward the browser to that URL. I jus...

Using RewritePath from an MVC controller action method

I am working in a hybrid MVC/Classical ASP.NET web application and I have to rewrite a URL at the controller level (because at a later stage I will be using a PageView, but for now it would be using the classical ASP.NET one), similar to this: public void Index(int Id) { HttpContext.Current.RewritePath("~/classic-aspnet-page.aspx?id="...

Zend Framework custom route isn't working at all

Hello, I've got a really weird problem with ZF (at least for ZF newbie): I can not access my existing controller and its action method. No problems with: localhost/ localhost/index localhost/index/index localhost/index/about But, I've set route like this: /localhost/test, pointing to index controller and indexAction and I see 404 ev...

II7 Rewrite Issues - excluding pages

Hey all, I've got a question about IIS7 rewrite. I'm wondering if there is a way to set conditions for re writing urls. I'm wanting to rewrite: http://www.domain.com/user.aspx?id=username to become http://www.domain.com/username/ I also have http://www.domain.com/article.aspx http:...