Forum Moderators: phranque
I've been browsing the forums for a while looking for an answer to this problem. Hope anyone can help
I'm using the following htaccess redirect so that a static .htm file redirects to its dynamic php file:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /[^.]+\.htm\ HTTP
RewriteCond %{REQUEST_URI} !^/encyclopedia/index.php?title=
RewriteRule ^(.*)\.htm$ /encyclopedia/index.php?title=$1 [R]
This works fine with files such as FIFA.htm or Chelsea_FC.htm
But it doesn't work with Chelsea_F.C..htm or F.C._Barcelona.htm
I imagine this is because the navigator believes that the extension is not .htm
How do I get around this? Thanks
I'd suggest:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^.]+\.)+htm\ HTTP
RewriteRule ^(.+)\.htm$ /encyclopedia/index.php?title=$1 [R=301,L]
The normal procedure is to use static URLs in your on-page links, internally rewrite those static URLs (when requested from your server) to the dynamic filepath needed to properly invoke your script, and then externally redirect any direct client requests for the dynamic URL back to the static URL, so that search engines display the nice clean static URL in search results.
This process is described fully in this thread [webmasterworld.com] in our forum library.
Jim