0

I have multiple php files which I had to convert to fixed html. All the php files are named in this way index.php?menu=XX (where XX is number from 1 to 80). I have named all my html files as indexXX.html (where XX is number from 1 to 80). But now I cannot find a way to write a redirect rule that would permanently redirect from (example) index.php?menu=17 to index17.html.

P.S. I've also tried to manually redirect as such (temporary redirect, since I'm testing):

Redirect 302 index.php?menu=6 index6.html

but I get a 500 internal error. If I use a slash before the filename then there's no error but I get a 404 saying index.php cannot be found.

anubhava
  • 761,203
  • 64
  • 569
  • 643
SkyNet
  • 104
  • 1
  • 6
  • indexXX.html you have 80 files? that's unusual, usually you would have one file and some code to handle the id –  Mar 13 '14 at 20:46
  • possible duplicate of [Reference: mod\_rewrite, URL rewriting and "pretty links" explained](http://stackoverflow.com/questions/20563772/reference-mod-rewrite-url-rewriting-and-pretty-links-explained) – mario Mar 13 '14 at 20:47
  • If you need more specific help, post the actual attempts, input and output URLs, and for http 500 results the according details from the error.log – mario Mar 13 '14 at 20:48
  • Yes, I had to convert 80 php files to html. Don't ask me why, I was just following orders :) And now I have to make sure all those php urls redirect to appropriate html files. – SkyNet Mar 13 '14 at 20:48
  • just following orders is no excuse in a military court ;) –  Mar 13 '14 at 20:50
  • Thank you for the related thread, I have read it, tried it but with no success. Whenever I try to redirect a php file with a parameter to html I get: The requested URL /index.php was not found on this server. – SkyNet Mar 13 '14 at 21:14

1 Answers1

0

permanently redirect from (example) index.php?menu=17 to index17.html.

You can use this rule as first rule

RewriteCond %{THE_REQUEST} \s/+index\.php\?menu=([^\s&]+) [NC]
RewriteRule ^ /index%1.html? [R=302,L]
anubhava
  • 761,203
  • 64
  • 569
  • 643