3

I'd like to rewrite /liam to /index.php/Liam_Edwards-Playne. I've currently written this below in the appropriate .htaccess file but it is still returning a 404:

RewriteEngine On
RewriteRule ^/liam$ %{DOCUMENT_ROOT}/index.php/Liam_Edwards-Playne [NC,L]
1
2

You shouldn't need the DOCUMENT_ROOT variable. Simply doing:

RewriteRule ^liam$ /index.php/Liam_Edwards-Playne [NC,L]

is sufficient for mod_rewrite

6
  • +1 Just to add, %{DOCUMENT_ROOT} could perhaps be used as part of the substitution in a server (virtualhost) context, but in a directory (.htaccess) context the substitution path must be relative to the DOCUMENT_ROOT, so it should be omitted.
    – MrWhite
    Jan 15 '13 at 8:18
  • It's not working, still getting a 404. Jan 15 '13 at 10:06
  • Double check that mod_rewrite is enabled.
    – joesk
    Jan 15 '13 at 11:11
  • 1
    Remove the slash at the start of the pattern. ^/liam$ becomes ^liam$. (In .htaccess files the directory prefix is removed when pattern matching.)
    – MrWhite
    Jan 15 '13 at 11:41
  • @w3d Oops! Grumble, grumble need moar coffee, grumble.
    – JCL1178
    Jan 15 '13 at 16: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.