mod_rewrite GUI? - .htaccess

Anyone have a graphical tool for developing mod_rewrite rules.
Ideally it would display a pipeline of rewrites and then when given an instance of a uri would show the transforms as the get applied.
It's always a pain to get them setup just right so any way of making it easier would help.

For online testing of .htaccess (read: mod_rewrite) rules, try:
http://htaccess.madewithlove.be/
It shows you what and how rules are applied to the input URL.

I dont know of any downloadable tools but there are a few helpful sites that I use to get the basics done:
http://www.webmaster-toolkit.com/mod_rewrite-rewriterule-generator.shtml
http://www.thejackol.com/htaccess-cheatsheet/

I think it’s quite hard to write one. Because mod_rewrite’s behavior is heavily dependent on the environment it’s used in.
Take for an example the -f expression for the RewriteCond directive to test if TestString exists and is a regular file in the file system. How would you do this without the actual file system?
Though the basic behavior (just the RewriteRule directive) could be implemented.

I am not aware of any such tool. The way I've addressed this problem was through a set of unit tests that are checking the correctness of my rules. If you want to have your tests always in synch with the config, you'll have to configure your tests to read the load the rules directly from the config file.
./alex

There is also a new webapp developed by technicalseo.com with help of mwl.be api they have nice gui with same functionality.
https://technicalseo.com/tools/htaccess/

Sounds like you're looking for an app like RegexBuddy.

Related

X-Frame-Options on torquebox-server

I'm struggling while getting a webpage running on my torquebox-server. The page itself is working fine, but to integrate this into another webiste I need to enable (or at least change them to another value) the X-Frame-options for the torquebox-server. I wasn' able to find something in the documentation, and there is also no part in the config file, which seems to be the correct place to change this.
Has someone already tried this or got this running on torquebox?
I would be very grateful, if someone could help me out..
Cheers Tim
After some morge research I've found out, that this isn't solvable with torquebox, but I just need to change my application. The application is using sinatra as framework, which uses Rack:Protection as a security module. In this module the "sameorigin" option is set (thanks to grep ;) ). Sinatra offers the possibility to exclude options from modules, in this case it was set :protection, :except => :frame_options
(found here)
So, maybe this is helpful for someone, who's having the same problem

Missing ARR Rewrite option in Failed Request Tracing

I am using Application Request Routing 3.0 with IIS's failed request tracing. I am having issues with my rewrite rules so I wanted to troubleshoot it.
I wanted to follow the steps below to enable IIS logging of rewrite rules but the option doesn't seem to be there for me.
http://www.iis.net/learn/extensions/url-rewrite-module/using-failed-request-tracing-to-trace-rewrite-rules
I am using Windows 2012 R2
If the Failed Request Tracing was installed after URL rewrite module,
the "Rewrite" area in Trace Providers may not be available. If you do
not see "Rewrite" area listed there, go to Add/Remove programs and
then run URL rewrite module installer in repair mode.
Original source
TLDR: you can also just reorder the FRT module to be listed BEFORE the urlrewrite module in IIS.
This simpler solution may appeal to some, versus that ms-documented suggestion to just reinstall urlrewrite. You can go to the server level in iis, choose the "modules" feature, and use its "view ordered list" option. There you will see (in this scenario above) that the Failed request trace module is listed AFTER the urlrewrite module--reflecting the fact that FRT was enabled AFTER urlrewrite was installed. It's an easy situation to end up in, and many then never realize how much frt can help with tracking rewrite rules.
But rather than reinstall urlrewrite (the stock answer), you can just move the frt module to be before urlrewrite, using the options offered there to move modules up or down. (The steps to do that are well-documented by MS and others, so I'll not elaborate them here.)
This way, the frt feature is loaded first and this can watch/track rewrite processing--again achieving the same goal as the proposed uninstall/reinstall of urlrewrite.
Hope that helps some. Sadly, even a lot of resources on using FRT to help debug rewrite rules don't acknowledge this surprisingly common problem, let alone either solution here.

Where to put node.js code in cPanel

I am entirely new to backend development so this might be a ridiculously easy and straightforward question, but I'm really not sure. I am trying to learn node.js for backend development, and all of the tutorials I have seen so far show how node can be used to run JavaScript from the terminal and create a server on local host. While this is a neat thing to do, I am stuck there and having difficulty understanding where to put my node.js code on cPanel and how to use it effectively along with the rest of my html/css/js code; all the examples I have seen are very isolated and don't have much interaction with these other files.
Again, I don't have any backend experience, so it would not be very helpful to explain this concept relative to another server-side language like Python, Ruby, or PHP, as I really have no idea where I would put any of the code for any of that stuff either or how it fits into the bigger picture. If the answer could maybe touch on how to integrate Python or PHP as well and general patterns for backend development---the easy stuff everyone assumes but no one explains---it would be much appreciated.
It doesn't matter where you put it. However you probably want to keep it in the folder of the username which is using it. I created a folder called app/ in my users folder and put all my crap in there. Then you simply set it up to listen on a port approved by your host.
You can use a .htaccess file in your public_html folder to redirect to the correct port number.
Your node.js will handle routing. So to go to certain css/html files you will have to set that up in your node.js code.

Import .htaccess rules in IIS using command line

Is it possible to import/convert a mod_rewrite .htaccess file to web.config using the command line (NOT using GUI as described here) and how ?
If it is not directly possible is there any workaround for this ?
It isn't possible to do this from the command line. The importer code is part of the UrlRewrite extension code and only surfaced via the IIS manager UI.
That said, if you have .NET Reflector (or a similar tool - ILSpy) you can inspect the code that performs the mod_rewrite translation.
From my own investigations, the UrlRewrite extension lives inside the following assemblies:
Microsoft.Web.Management.Rewrite
Microsoft.Web.Management.Rewrite.Client
These reside in the GAC and can be opened quite easily for inspection by .NET Reflector.
The classes and methods of interest are:
Microsoft.Web.Management.Iis.Rewrite.Translation.ImportRulesPage.Translate()
which calls:
Microsoft.Web.Management.Iis.Rewrite.Translation.Translator.Translate()
From this information it may be possible to reverse engineer your own command line implementation.

Can't read query string if default index file name is omitted?

Is there an issue with IIS or ASP Classic where Request.ServerVariables("QUERY_STRING") returns blank if no default file name is given in the URL? On my local developer machine, I can do
http://localhost/xslt/?opcs/abc
which returns "opcs/abc". However, on our ancient web server, it returns nothing. I have to explicitly give it the default file name in the URL. Like so
http://localhost/xslt/default.asp?opcs/abc
While nothing too major, it is a little bit of a annoyance. One way I can maybe think of remidying the problem is have Javascript read the URL and return everything after the ?.
Unfortunately, I do not know what version of IIS or ASP we are using.
Thank you.
That sounds like a bug, I never experienced that when I used to do a lot of ASP. Make sure you are patched up to the latest version.
If you're running IIS 4.0, this may very well be the case. So you're really stuck with this ancient piece of software (and probably hardware) ? :)

Resources