Forum Moderators: phranque
DirectoryIndex myfile.html
Redirect 301 / http://localhost/mydomain/myfolder/myfile.html
#OR
RewriteEngine On
RewriteCond %{HTTP_HOST} ^/$
RewriteRule ^$ http://localhost/mydomain/myfolder/myfile.html [L,R=301] DirectoryIndex index-file.html
RewriteEngine On
RewriteCond %{THE_REQUEST} ^.*\/index-file\.html?
RewriteRule ^(.*)index-file\.html?$ http://localhost/mydomain/myfolder/$1 [R=301,L] # Strip / from .html/ or any extension at any folder depth.
RewriteRule ^(([^/]+/)*[^/.]+\.[^.]+)/$ http://www.example.com/$1 [R=301,L] # Redirect named index files to URL ending in /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index-file\.html?
RewriteRule ^([^/]+/)*index-file\.html?$ http://www.example.com/$1 [R=301,L] Options +FollowSymLinks
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*myindex-page\.html?
RewriteRule ^([^/]+/)*myindex-page\.html?$ http://localhost/websitefolder/$1 [R=301,L] http://localhost/websitefolder/folder1/folder2/as expected
http://localhost/websitefolder/folder2/404 error
http://localhost/websitefolder/folder1/folder2/myindex-file.htmdirectly into the browser.
#redirect# GET /websitefolder/folder2/
http://localhost/websitefolder/folder2/
GET /websitefolder/folder2/ HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
HTTP/1.1 404 Not Found
Date: Thu, 17 Nov 2011 13:26:24 GMT
Server: Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1
Vary: accept-language,accept-charset
Accept-Ranges: bytes
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1
Content-Language: en
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*myindex-page\.html?
#
RewriteRule ^ [L] RewriteRule ^ [L] RewriteRule myindex-page\.html? - [L] href="../index.html" href="../" href="index.html" href="./" ../ construct in links to other pages, images or stylesheets that are pulled by the web browser. http://www.example.com/folder/page are in the form href="../otherfolder/otherpage".