Anybody know an online tool to generate Apache mod_rewrite
rules to point people with simple .htaccess questions to?
I'm thinking of simple standard scenarios:
Simple redirects (url1
=>url2
)
Removing / adding www.
/a/b/c/d
to index.php?value1=a&value2=b...
and so on and so on....
I'm asking because most mod_rewrite questions turning up on SO could be answered with a link to that, and help people help themselves (well, help as far as "help" goes with a generator tool that can be used without actually having to learn how things work.)
In your rewrite, the ^ signifies the start of the string, the (. *) says to match anything, and the $ signifies the end of the string. So, basically, it's saying grab everything from the start to the end of the string and assign that value to $1.
Step 1 — Enabling mod_rewrite In order for Apache to understand rewrite rules, we first need to activate mod_rewrite . It's already installed, but it's disabled on a default Apache installation. Use the a2enmod command to enable the module: sudo a2enmod rewrite.
htaccess rewrite rules can be used to direct requests for one subdirectory to a different location, such as an alternative subdirectory or even the domain root. In this example, requests to http://mydomain.com/folder1/ will be automatically redirected to http://mydomain.com/folder2/.
L (last - stop processing rules) Last rule: instructs the server to stop rewriting after the preceding directive is processed. N (next - continue processing rules) NC (case insensitive) NE (do not escape special URL characters in output)
Even more such questions could be solved with a link to the manual.
If we provide only a link to a generator, the answer has no educational value, and will result only in more trivial questions asked. I'd recommend reading answers to this question form meta, which contains some relevant discussion.
That said, a quick google search has returned some useful results:
/c/d
=> index.php?a=b&c=d
A cheap google search has two that exist.
I've tried three so far. I like this one the most so far:
Also, if you need a tool to test these results:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With