Redirecting links without a .html extension to link with .html extension
After changing my site structure I need help redirecting links. How can I redirect all links that don't have a .html extension to the same link but with .html extension? The only link I don't want redirected is /admin.
Example: google.com/hey -> google.com/hey.html
google.com/hey.html -> do noth开发者_开发知识库ing
google.com/admin -> do nothing
Thanks in advance
Ohh sorry, try this man. The error was in the rewritecond.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !\.html$
RewriteRule (.+) $1.html [L]
If these links are onpage links an non external ones a .htaccess solution could help. First be aware to use htaccess only if you do not have access to the server config, because htaccess slows the server down. Everything configured there can be configured as well in the .httpdconf
Sorry, I have not tested the code posted bellow but tell me if it has worked. http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} > \.html
RewriteRule (.+) $1.html [L]
精彩评论