0
RewriteEngine on
RewriteRule ^home index.php [NC,L]
RewriteRule ^news news.php [NC,L]

Would appreciate any help on how to address this. I have created a .htaccess file for my site in order to simplify its URLs. The entire .htaccess reads as follows (and works as desired):

RewriteEngine on

The only issue I'm facing now is that clicking on it generates a Server Error 500 page instead of the facebook share window.

What can I do to fix this issue

anubhava
  • 761,203
  • 64
  • 569
  • 643
Agni Scribe
  • 252
  • 3
  • 18

1 Answers1

1

You should use end anchor in your patterns and turn MultiViews off:

Options -MultiViews
RewriteEngine on

RewriteRule ^home/?$ index.php [NC,L]
RewriteRule ^news/?$ news.php [NC,L]
RewriteRule ^news/([0-9a-z]+)/?$ news.php?id=$1 [NC,L,QSA]

Without end anchor ^news pattern will also match news.php and cause infinite looping and eventually 500 (internal server error).

anubhava
  • 761,203
  • 64
  • 569
  • 643
  • Can you check your Apache error.log and see what the error is there – anubhava Feb 15 '16 at 16:53
  • the error.log doesnt seem to give any corresponding errors: the last in the log: [Mon Feb 15 07:37:03.244715 2016] [mpm_winnt:notice] [pid 7708:tid 268] AH00354: Child: Starting 150 worker threads.` On the other hand the full server error message is: `The website encountered an error while retrieving https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Flocalhost%2Fexperiment%2Fprefinalkoh%2Fnews%3Fid%3D6. It may be down for maintenance or configured incorrectly.` – Agni Scribe Feb 15 '16 at 17:04
  • From another SO q thread found that By default, PHP does NOT log these errors - so will have to take some steps to enable internal server logging. hold on. – Agni Scribe Feb 15 '16 at 17:19
  • have set `display_errors = On` `display_startup_errors = On` and `error_reporting = E_ALL`, but doesnt seem to generate error log for this issue. any way to guess what the 500 error issue could be caused by? – Agni Scribe Feb 15 '16 at 17:50
  • That is for PHP errors and this 500 is Apache error. You should contact your hosting admin to figure out where is `error.log` located – anubhava Feb 15 '16 at 18:08
  • I already found the log - that's where i got the last error from: Mon Feb 15 07:37:03.244715 2016] [mpm_winnt:notice] [pid 7708:tid 268] AH00354: Child: Starting 150 worker threads.` but it has no relation to error 500 – Agni Scribe Feb 15 '16 at 18:09
  • would appreciate if you could either continue the thread of the comments - or remove ur answer - so i can reissue this question. i appreciate the time you have taken so far and can understand that you may not want to take this thread forward. in which case it would help if i could at least reissue this question to cast for more possible solutions. – Agni Scribe Feb 15 '16 at 19:18
  • I have already told you the precise instruction to either check the correct `error.log` or contact your hosting admin if you cannot get it yourself. – anubhava Feb 15 '16 at 19:23
  • Like i said, I have checked the correct error.log and this is on localhost. – Agni Scribe Feb 15 '16 at 19:24
  • To check whether it is correct log file try putting same garbage (random) text on top of your `.htaccess` and see if it generates 500 (internal server) error or not when you visit your page in browser. It should also write a precise error message in the error.log file – anubhava Feb 15 '16 at 19:26
  • The browser gave the following error: `Server error! The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script. If you think this is a server error, please contact the webmaster. Error 500 localhost Apache/2.4.17 (Win32) OpenSSL/1.0.2d PHP/5.6.15` – Agni Scribe Feb 15 '16 at 19:32
  • The errorlog gave this: `C:/xampp/htdocs/experiment/PrefinalKoH/.htaccess: Invalid command 'SADasdDS', perhaps misspelled or defined by a module not included in the server configuration, referer: http://localhost/experiment/prefinalkoh/news` – Agni Scribe Feb 15 '16 at 19:32
  • No reference in the log to the server error 500 as far as i can see; though it is referred to in the browser – Agni Scribe Feb 15 '16 at 19:32
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/103526/discussion-between-anubhava-and-agni-scribe). – anubhava Feb 15 '16 at 19:40