Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite test app/script

standalone app to test mod_rewrite?

         

Grimmjow

8:28 am on Jul 25, 2008 (gmt 0)

10+ Year Member



Hi,

I was looking for a standalone utility/app/script that would let me test mod_rewrite rules/conds to avoid edit+upload+refresh+see_what_happens_on_the_browser.

The reason is that I'm still at the stage which I can't write the right rules/conds at the first try, and when a rewrite doesn't work, not always the reason is clear from the message dumped by the server on the browser, if any. Coming and ask for the solution is not the right thing to do either, because while I'll solve for that particulr problem, but I will never fully learn how it works on my skin ninthis way.

So I'd like to have this tool, where I put my rewrite .htaccess content, I put a test URL such I was typing in the browser address bar, and the tool applies the rewrite rules and show me the result.

Does anything like that exist?

Thanks in advance

nick279

11:15 am on Jul 25, 2008 (gmt 0)

10+ Year Member



You can always download a version of WAMP or XAMPP to test your rewrites on a local machine, but I'm not sure about an app.

Is a really good idea for an app though!

Samizdata

12:53 pm on Jul 25, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Surely the testing app you need is called Apache?

All .htaccess does is override the main Apache configuration (where that configuration allows).

Apache is a free download, and as suggested above there are other free programs that enable simple installation on Windows machines - and all Macs come with a version of Apache built-in.

The real trick is configuring your local development server to be as similar as possible to the one the live site is hosted on - presumably you use a shared hosting company, and they have many different setups and restrictions, including different ways of installing PHP and other packages. They will also be running on a particular flavour of Linux configured in a particular way.

Don't let that put you off though - it's not difficult to get a "close enough" replication of your hosting environment, and you won't have to risk potentially dangerous experiments on a live site.

...

jdMorgan

1:04 pm on Jul 25, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In addition to the "message dumped by the server on the browser," the server access log and the server error log, taken together, will often provide a lot of useful information.

I don't know of any "mod_rewrite testers," but there are many on-line "regular-expressions testers/evaluators." If your problem is primarily with getting the regex patterns correct, then these may be helpful.

Other than that, you could use my method, which is simply to experiment intensely, make as many mistakes as possible as fast as possible, and learn from them... ;)

Jim

nick279

2:35 pm on Jul 25, 2008 (gmt 0)

10+ Year Member



Suppose you'd need a free port, a super-lightweight installation of apache all embedded into an application, and some sample lipsum pages for each rewrite, along with a textarea-like htaccess editing field.

Grimmjow

10:55 pm on Jul 25, 2008 (gmt 0)

10+ Year Member



Thanks for the answers.

Well, I already have installed Apache+PHP+MySQL on my machine because I regulary devolop, so maybe I just have to try to browse those Apache logs. My problem is that my knowloedge is splitted in 5% for Apache, 55% for PHP and 40% MySQL, this is my problem.

jdMorgan wrote: Other than that, you could use my method, which is simply to experiment intensely, make as many mistakes as possible as fast as possible, and learn from them... ;)

No doubt I make alot of mistakes, and that way I learnt almost everything, but what it slows down me sometimes when testing .htaccess mods is the lack of feedback, whereas other tools offers more detailed informations, but maybe is all dumped in those logs, and I didn't check :D

jdMorgan

12:09 am on Jul 26, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Once you've got your own server set up, there is another tool you can use, since you will have access to httpd.conf on that server: A RewriteLog can be enabled, and you can select how 'verbose' it will be.

This will likely help you a lot. Unfortunately, since most Webmasters are on shared servers, they have no access to the RewriteLogging facility, since it is controlled only by the hosting company.

BTW, one thing I wanted to mention before is this: Half of the complexity of mod_rewrite is in the regular expressions. If you are having trouble with them, I can offer one bit of opinion/advice: It is much easier to write regular expressions than to read them. Therefore, learning them is rather slow, but once mastered, becomes almost trivial. Since mod_rewrite has so few directives, learning them is not hard. But the biggest challenge is in designing URL and filesystem structures with mod_rewrite in mind, and in specifying the requirements for the mod_rewrite code to map URLs to filenames. Once the URL structure, files organization, and URL-to-filesystem rewriting requirements are well-specified, writing the code itself is (eventually) trivial compared to these other tasks.

Jim