apache.htaccessurlmod-rewriterewriting

Rewriting mulitple URLS


I am trying to rewrite different URLs. The first three lines work, but lower ones do not. I get a 500 Internal Server Error. A snippet of my htaccess file:

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^word/(.*)$ word.php?word=$1 [QSA]

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^/en/word/(.*)$ /en/word.php?word=$1 [QSA]

It would be very nice if someone could help me, as I can't find a solution. What am I doing wrong?

Greetings, Andreas


Solution

  • With your shown samples, please try following. Please keep your .htaccess file inside your root folder.

    Please make sure to clear your browser cache before testing your URLs.

    RewriteEngine ON
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^word/(.*)$ word.php?word=$1 [QSA,NC,L]
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^en/word/(.*)$ en/word.php?word=$1 [QSA,NC,L]