Pacific Beach, San Diego doesn't redirect to anything, but it is the redirect target of a number of resources:
is dbo:wikiPageRedirects of
- dbr:Pacific_Beach,_CA
- dbr:Pacific_Beach,_California
- dbr:Pacific_Beach,_San_Diego,_CA
- dbr:Pacific_Beach,_San_Diego,_California
- dbr:Pacific_Beach,_San_Diego_California
That means that a modified version of your query should work just fine:
PREFIX s: <http://dbpedia.org/resource/Pacific_Beach,_San_Diego>
PREFIX dbp: <http://dbpedia.org/property/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT * WHERE {
OPTIONAL { s: dbp:officialName ?officialName . }
OPTIONAL { s: dbp:name ?foaf_name . }
#-- ... [ about 20 more lines like the above ] ...
} LIMIT 2
SPARQL results
Note that using prefix to abbreviate a single IRI is sort of unusual. It would be more common to use a values block to bind a specific variable, that you can use in the rest of your query. That is, I would write that query as:
PREFIX dbp: <http://dbpedia.org/property/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT * WHERE {
values ?s { <http://dbpedia.org/resource/Pacific_Beach,_San_Diego> }
OPTIONAL { ?s dbp:officialName ?officialName . }
OPTIONAL { ?s dbp:name ?foaf_name . }
#-- ... [ about 20 more lines like the above ] ...
} LIMIT 2;
That has the advantage that if you want to search values for additional cities, you can just add them to the list of values. Now, if you want to add a value that redirects to something else, that's not a problem. You'd just want to add a non-optional pattern that helps you follow to the redirect targets:
SELECT * WHERE {
values ?x { <http://dbpedia.org/resource/Pacific_Beach,_California> }
?x dbo:wikiPageRedirects* ?s .
OPTIONAL { ?s dbp:officialName ?officialName . }
OPTIONAL { ?s dbp:name ?foaf_name . }
#-- ... [ about 20 more lines like the above ] ...
} LIMIT 2
SPARQL results
As a final note, do be careful that if you're copying and pasting URIs from the browser that you make sure to use the right URI in the query. When you visit a DBpedia resource, e.g., http://dbpedia.org/resource/foo in the browser, you're redirected to the human readable form http://dbpedia.org/page/foo in the browser. That's just a quirk of DBpedia. (Really, they should use content-type negotiation and just return an HTML document for the former when a web browser is making the request.)