Reputation: 682
I am attempting to make a rewrite rule to map a prettified URI folder path to an ugly one.
The URI I am trying to map:
/project/IDHERE/TITLEHERE{optional) to
/project.php?pid=id&pttl=title
with
RewriteRule ^project/(.*)/$(.*)?/$ project.php?pid=$1&pttl=$2
however when I try and use this rule, the sever throws a 500 server error message. Apache Rewrite docs are rather painfully confusing (not sure if I'm alone in thinking this).
Any help would be appreciated.
Upvotes: 1
Views: 45
Reputation: 291
I'm assuming it's because you have two end of pattern identifiers... i.e. the "$"
Maybe try, disclaimer: (UNTESTED)
RewriteRule project/([^/]*)(?:/([^/]*))?/$ project.php?pid=$1&pttl=$2
And to state the obvious make sure
RewriteEngine On
Has been stated.
The above example also REQUIRES a trailing slash. You could have the trailing slash optional using the following:
RewriteRule project/([^/]*)(?:/([^/]*))?/?$ project.php?pid=$1&pttl=$2
Upvotes: 1