Say the path of your URL is:
/thisisa"quote/helloworld/
Then how do you create the rel=canonical
URL?
Is this kosher?
<link rel="canonical" href="/thisisa&quot;/helloworld/" />
UPDATE
To clarify, I'm getting a form submission, I need to convert part of the query string into the URL. So the steps are:
- .htaccess does the redirect
- PHP processes a directory as a query string.
- The query string will be dynamically inserted into the:
- Title,
- Description,
- Keywords
- Canonical URL.
- Spit back into the form's input box
So I need to know which processing has to be done each step of the way...On the first cut, this is my take:
- Title:
htmlspecialchars($rawQuery)
- Description:
htmlspecialchars($rawQery)
- Keywords:
htmlspecialchars($rawQuery)
- Canonical URL: This is the tricky part. It must match the same URL .htaccess redirects to but even so, I think the raw query is unsafe because quotes can cause JavaScript injection. Worried about
urlencode($rawquery)
since it's coming from the URL, wouldn't it already be URL-encoded? - Spit back into form:
htmlspecialchars($rawQuery)