0

I tried to set this RewriteCond in httpd 2.4.4:

...
RewriteCond expr "%{QUERY_STRING} =~ /welcome/"
RewriteRule ^(.*)$ %1\.html

So, if I visit https://localhost/?welcome , for example, I should see the page https://localhost/welcome.html.

Instead, it returns a 500 Internal Server Error. Why?

The error log reads:

Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

2
  • On HTTP 500 there should be something in your error.log – Pascal Schmiel Jun 6 '13 at 11:12
  • @PascalSchmiel Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace. – sl34x Jun 6 '13 at 11:15
0

Try:

RewriteCond %{QUERY_STRING}  (welcome)
RewriteRule ^.*$ %1.html

This replaces the %1 with the matching group from the RewriteCond. Because you are using here a static string you can just use:

RewriteCond %{QUERY_STRING}  welcome
RewriteRule ^.*$ welcome.html
19
  • I understand, but it redirects me on /.html not /welcome.html. Why is that? – sl34x Jun 6 '13 at 11:27
  • tried this on my own and edited my answer. – Pascal Schmiel Jun 6 '13 at 11:44
  • and if I use a dynamic string? – sl34x Jun 6 '13 at 11:53
  • Then you can use the expression you want in your RewriteCond, put it in brackets an reference to it using %1 - exactly like in the first example - but use some expression instead of "welcome" – Pascal Schmiel Jun 6 '13 at 12:35
  • Yes, but i meant concatenate the %1 and some other string, such as %1pageoftoday . How could i do? – sl34x Jun 6 '13 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.