I tried it with the WordPress rewrites ( <a href="http://codex.wordpress.org/Using_Permalinks" rel="nofollow">http://codex.wordpress.org/Using_Permalinks</a> ) and I couldn't get it to work. I think the problem is that I didn't know what to put in REQUEST_FILENAME. I tried the following:<p>REQUEST_FILENAME: I tried blank, "year/month/day/post-name" and "/year/month/day/post-name".<p>URL: year/month/day/post-name (to give hostname/year/month/day/post-name).<p>Rewrite rules copied from the WP link above:<p><pre><code> # BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
</code></pre>
I got one no match and two rules skipped.<p><i>EDIT</i>: You have an XSS vulnerability in the URL field. Use the first test from this list: <a href="http://ha.ckers.org/xss.html" rel="nofollow">http://ha.ckers.org/xss.html</a> .
Very handy - worked well for a couple of simple rules; it'd be good to see more feedback when it can't handle something (e.g. feeding it the rules from <a href="http://stackoverflow.com/questions/992565/why-isnt-this-rewrite-rule-working" rel="nofollow">http://stackoverflow.com/questions/992565/why-isnt-this-rewr...</a> just results in a greyed-out URL field).<p>Trivial nit: backslashes are doubled when rules are restored from the session.
Wow, this is a great idea! One idea, maybe add a small disclaimer or something at the bottom stating that any saved rewrite rules are private - rewrite rules often contain paths to scripts/pages on the filesystem that many people would never wish to reveal to the public. Or, make the storage functionality optional so real privacy freaks can turn it off.<p>I will definitely use this next time I have to hack 'n slash some rewrite rules though!
Very useful indeed, thanks!<p>I'm missing one important feature though: there is no way to test different host names. I use rewrite rules that check country specific TLDs on the domain name and also rules that check if the domain starts with "m." for mobile specific access by matching against %{HTTP_HOST}. This would also allow one to check if the URL is using an IP address instead of a domain name. This would seem a common need, right?
Had quick run at it and it seems to work nicely. I spend half my life dealing with rewrites of varying complexity so this might well save me some time!
It would be great if you would allow for multiple test URLs, i.e. make the “Enter a URL” input field a textarea that accepts a new URL on every line.<p>Another suggestion: why not just use localStorage instead of a $_SESSION?