htaccess redirect index

auch im seohype oder einfach nur interessiert an eindeutigen links? rief mich heute ein freund an und fragte mich nach einem weg um domain.tld/ nach domain.tld/index.php umzuleiten. der vernünftigste weg führt wohl über die htaccess – tricky like stairs?!

example #1: domain.tld/ -> domain.tld/index.php

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{HTTP_HOST} ^domain.tld$
RewriteRule ^$ http://%{HTTP_HOST}%{REQUEST_URI}index.php [L,R=301]

example #2: domain.tld/subdir/ -> domain.tld/subdir/index.php

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/subdir/$
RewriteCond %{HTTP_HOST} ^domain.tld$
RewriteRule ^$ http://%{HTTP_HOST}%{REQUEST_URI}index.php [L,R=301]

tricky-stairs

29.11.2009