TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: please review my tool for rewrite rule testing

32 pointsby mmelinover 14 years ago

8 comments

pierrefarover 14 years ago
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 &#60;IfModule mod_rewrite.c&#62; RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] &#60;/IfModule&#62; # 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> .
评论 #2048837 未加载
评论 #2048952 未加载
thepsiover 14 years ago
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.
评论 #2048870 未加载
petervandijckover 14 years ago
Haven't actually tried it, but anything that helps with mod_rewrite is gonna be useful :)
ecarothover 14 years ago
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!
speledingover 14 years ago
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?
评论 #2048724 未加载
评论 #2048846 未加载
kingofspainover 14 years ago
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!
mathiasover 14 years ago
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?
alissonover 14 years ago
Its definitely going to make my life with debugging mod_rewrite rules so much easier. Thanks =D