6

I have read around for a while and I can't get this to work.

mod_rewrite is enabled in Apache and I have changed AllowOverride to all

My .htaccess looks like this:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ profile.php/?username=$1 [L]

and my default file for apache2 looks like this: ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
            Options FollowSymLinks
            AllowOverride all
    </Directory>
    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride all
            Order allow,deny
            allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

error.log

[Sat May 25 20:13:21 2013] [alert] [client (ip)] /var/www/.htaccess: Invalid command '\xef\xbb\xbfRewriteEngine', perhaps misspelled or defined by$
[Sat May 25 20:13:21 2013] [alert] [client (ip)] /var/www/.htaccess: Invalid command '\xef\xbb\xbfRewriteEngine', perhaps misspelled or defined by$
[Sat May 25 20:13:22 2013] [alert] [client (ip)] /var/www/.htaccess: Invalid command '\xef\xbb\xbfRewriteEngine', perhaps misspelled or defined by$
[Sat May 25 20:13:23 2013] [alert] [client (ip)] /var/www/.htaccess: Invalid command '\xef\xbb\xbfRewriteEngine', perhaps misspelled or defined by$
[Sat May 25 20:14:56 2013] [alert] [client (ip)] /var/www/.htaccess: Invalid command '\xef\xbb\xbf', perhaps misspelled or defined by a module not$
[Sat May 25 20:14:57 2013] [alert] [client (ip)] /var/www/.htaccess: Invalid command '\xef\xbb\xbf', perhaps misspelled or defined by a module not$
[Sat May 25 20:14:59 2013] [alert] [client (ip)] /var/www/.htaccess: Invalid command '\xef\xbb\xbf', perhaps misspelled or defined by a module not$
[Sat May 25 20:14:59 2013] [alert] [client (ip)] /var/www/.htaccess: Invalid command '\xef\xbb\xbf', perhaps misspelled or defined by a module not$
[Sat May 25 20:15:04 2013] [alert] [client (ip)] /var/www/.htaccess: Invalid command '\xef\xbb\xbfRewriteEngine', perhaps misspelled or defined by$
[Sat May 25 20:15:04 2013] [alert] [client (ip)] /var/www/.htaccess: Invalid command '\xef\xbb\xbfRewriteEngine', perhaps misspelled or defined by$
[Sat May 25 20:15:20 2013] [alert] [client (ip)] /var/www/.htaccess: Invalid command '\xef\xbb\xbfRewriteEngine', perhaps misspelled or defined by$
[Sat May 25 20:15:20 2013] [alert] [client (ip)] /var/www/.htaccess: Invalid command '\xef\xbb\xbfRewriteEngine', perhaps misspelled or defined by$
[Sat May 25 20:15:58 2013] [notice] caught SIGTERM, shutting down

On my website I get a 500 internal server error message. Please help!

TheMeisterSE
  • 541
  • 1
  • 7
  • 28
  • 1
    _“On my website I get a 500 internal server error message.”_ – then look into the server’s error logs! – CBroe May 26 '13 at 00:34
  • Just added the error.log, going to add access.log aswell if it shows anything. – TheMeisterSE May 26 '13 at 00:37
  • As anubhava already said, that looks like your file is a little messed up – `\xef\xbb\xbf`, that seems to be a Byte Order Mark. If apache complains about this on the second line of your file, then it looks like you edited an UTF-8 encoded file with an editor that does not handle this correctly while adding the first line or something. _Type_ (not copy&paste) those lines into a new file again, and save it as plain ASCII – that should solve this problem. – CBroe May 26 '13 at 10:26
  • @CBroe Yes, it was as anubhava said. I couldn't see it in my text editor (Notepad++) but when I opened the file within SSH there was some strange characters in the beginning. – TheMeisterSE May 26 '13 at 11:14

1 Answers1

2

Try changing your code to this:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ profile.php/?username=$1 [L]

i.e. turn the MultiViews options off.

PS: Looking at your error.log looks like you have some special characters in your .htaccess before RewriteEngine keyword.

anubhava
  • 761,203
  • 64
  • 569
  • 643