Redirect name.html to /name
23. Mai 2016 / apache2
×Info: This post is older than 2 years! Displayed information may be outdated!
Aus aktuellem Anlass: aus static HTML-page wird CMS oder Framework: alte HTML-Seiten in schöne / friendly-Urls redirecten (301 moved permanently). Vorteil: SEO konform. Google-Rank soll(te) nicht darunter leiden.
# vhost config
RewriteEngine On
#RewriteBase /path/to/app # only when used in .htaccess file
# start redirect old urls (permanently)
RewriteCond %{HTTP_HOST} ^www.domain.de$ [NC]
RewriteRule ^services\.html$ /leistungen [R=301,L]
RewriteRule ^imprint\.html$ /impressum [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L] # dispatcher of used framework
# flags explained
# L Last rule (stop when matched and redirect)
# NC case insensitive
# R=301 moved permanently
Einen schönen Online-Rewrite-Tester gibts hier: http://htaccess.mwl.be/
Wichtig: Protkoll (z.B. http://) beim Testen von Urls mit reinschreiben!