Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rewrite rule generator? [closed]

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.)

like image 977
Pekka Avatar asked Sep 12 '10 11:09

Pekka


People also ask

What is $1 rewrite rule?

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.

How do I turn on rewrite mode?

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.

What is rewrite rule in htaccess?

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/.

What is L rewrite rule?

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)


2 Answers

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:

  • http://www.generateit.net/mod-rewrite/ generates rules for /c/d => index.php?a=b&c=d
  • http://tools-for-webmasters.com/mod_rewrite_tool.html this one currently moved to https://www.301-redirect.online/htaccess-rewrite-generator
like image 121
Mewp Avatar answered Sep 18 '22 18:09

Mewp


A cheap google search has two that exist.

I've tried three so far. I like this one the most so far:

  • Generate it - http://www.generateit.net/mod-rewrite/
  • htaccess url rewrite generator - http://www.myseotool.com/free-seo-tools/htaccess-url-rewrite-generator.php Doesn't work anymore.

Also, if you need a tool to test these results:

  • apache rewrite tester: http://martinmelin.se/rewrite-rule-tester/
like image 24
chrisjlee Avatar answered Sep 17 '22 18:09

chrisjlee