0

I am trying to enable the rewrite engine on my .htaccess file, but I encounter 500 Internal Server Error.

I am using Apache/2.4.18 (Ubuntu) Server

following some examples in ubuntu community, they suggest to change the < Directory > in the apache2.conf. I made this change so my directory is looking like this

<Directory /home/user/public_html/>
    Options Indexes FollowSymLinks
   AllowOverride All
   Require all granted
</Directory>

in the error.log file i have this error

[Wed May 03 19:08:42.212552 2017] [core:alert] [pid 7729] [client 127.0.0.1:43650] /home/user/public_html/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration

when I remove the .htaccess file everything works fine

here is my .htaccess file

RewriteEngine On

RewriteRule ^katastimata adrianio-udragogio.php [NC, L]
Sourav Ghosh
  • 1,964
  • 4
  • 33
  • 43
vaggelis
  • 60
  • 2
  • 9
  • Can you post the whole .htaccess file? – Jaime May 03 '17 at 16:38
  • 1
    Possible duplicate of [How to enable mod\_rewrite for Apache 2.2](http://stackoverflow.com/questions/869092/how-to-enable-mod-rewrite-for-apache-2-2) – ChrisGPT was on strike May 03 '17 at 16:39
  • 1
    The error log states what the problem is... you don't have mod_rewrite installed. – MrWhite May 03 '17 at 16:40
  • @Jaime i edited my post, now there is the .htaccess file – vaggelis May 03 '17 at 16:42
  • (Although you also have an error in the `RewriteRule` directive that would also result in a 500 error (if you had mod_rewrite installed)... there should be no spaces in the `RewriteRule` _flags_ argument.) – MrWhite May 03 '17 at 16:56
  • @w3dk what do you mean i havent install mod_rewrite? i have made all the configurations and i have run the sudo a2enmod rewrite. but still nothing works.i didnt get the error in the RewriteRule – vaggelis May 03 '17 at 16:57
  • The rewrite module itself (aka mod_rewrite) needs to be enabled/installed on your server if it's not already - this is explained in the linked question. mod_rewrite is not a core module. All you've really done in your `` block is to enable the use of `.htaccess` files. The error from your log states: "Invalid command 'RewriteEngine' ... defined by a module not included in the server configuration". The module that's not included is mod_rewrite - this needs to be specifically loaded in your server config. – MrWhite May 03 '17 at 17:07
  • can you please explain me where is the space in my RewriteRule which makes the error? – vaggelis May 03 '17 at 17:08
  • If you've done all the necessary steps and you are still getting that error then I'm not sure... but that's what that error is reporting. You won't get the error reported about the `RewriteRule` until mod_rewrite is enabled - another indication that it's not enabled. – MrWhite May 03 '17 at 17:09
  • There must not be a space in the `RewriteRule` _flags_ argument. ie. `[NC, L]` should be `[NC,L]` (no space). Spaces are delimiters in Apache config files, so any erroneous spaces are likely to break something. – MrWhite May 03 '17 at 17:10
  • i run in my terminal sudo a2enmod rewrite and i get Module rewrite already enabled.so this means that is enabled but not included? – vaggelis May 03 '17 at 17:13
  • you were right the problem was the space in the flags.thanks for your help @w3dk cheers :) – vaggelis May 03 '17 at 17:15
  • You're welcome, glad you got it sorted. However, if "the problem was the space in the flags" then you would have expected to see a different error, something like: "RewriteRule: bad flag delimiters". (?) – MrWhite May 03 '17 at 17:21

0 Answers0