Forum Moderators: phranque
I tried RewriteRule ^(.*)/+$ $1 [R=301,L] http://example.net/home3/pintotou/public_html/Asia/Indonesia/bali.php
http://example.net/Asia/Indonesia/bali.php
http://example.net/Asia/Indonesia/bali.php
[edited by: phranque at 9:30 am (utc) on Feb 21, 2014]
[edit reason] Please Use example.com [webmasterworld.com] [/edit]
Here it would be
^([^/]+/)*
or rather-- ahem, oops, my bad--
^(([^/]+/)*)
so the whole thing gets captured. Or, if you have no literal periods anywhere,
^([^.]*)index\.html
RewriteRule ^(([^/]+/)*)index\.html http://www.example.com/$1 [R=301,L] ^[A-Z]{3,9}\ (([^/]+/)*)index\.html\ HTTP index\.html I would have thought this instruction (#bandwidth...) should come after the index redirect.
#4a index redirect
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html
RewriteRule ^(.*)index.html$ http://example.net/$1 [R=301,L]
#4b domain-name canonicalization redirect
RewriteCond %{HTTP_HOST} !^(example\.net)?$ [NC]
RewriteRule ^(.*)$ http://example.net/$1 [R=301]
RewriteRule ^(([^/]+/)*)index\.html http://www.example.com/$1 [R=301,L]
#Use PHP5.4 Single php.ini as default
AddHandler application/x-httpd-php54s .php
#
AddType text/x-component .htc
#Do not allow access to the directories -For security reasons, Option followsymlinks cannot be overridden.
Options -Indexes +SymLinksIfOwnerMatch
RewriteEngine on
#1 # block visitors referred from indicated domains
RewriteCond %{HTTP_REFERER} semalt\.com [NC,OR]
RewriteCond %{HTTP_USER_AGENT} libwww-perl
RewriteRule .* – [F]
#2 bandwidth theft
RewriteCond %{HTTP_REFERER} !^http://example\.net/
RewriteRule .*\.(jpe?g|gif|png|bmp)$ - [F]
#3 redirects from file that changed name
#3a
RewriteRule ^Pinto/oldindex\.html http://example.net/Pinto/oldindex.php [R=301,L]
# 3b
RewriteRule ^Asia/Indonesia/bali\.html http://example.net/Asia/Indonesia/bali.php [R=301,L]
# 3c
RewriteRule ^Asia/Indonesia/indonesia\.html http://example.net/Asia/Indonesia/indonesia.php [R=301,L]
#4a index redirect
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html
RewriteRule ^(([^/]+/)*)index\.html http://example.com/$1 [R=301,L
#4b domain-name canonicalization redirect
RewriteCond %{HTTP_HOST} !^(example\.net)?$ [NC]
RewriteRule ^(.*)$ http://example.net/$1 [R=301]
#5
# BEGIN EXPIRES
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 10 days"
ExpiresByType text/css "access plus 1 week"
ExpiresByType text/plain "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 week"
ExpiresByType application/x-icon "access plus 1 year"
</IfModule>
# END EXPIRES
<ifModule mod_deflate.c>
<filesMatch "\.(js|css|html|php)$">
SetOutputFilter DEFLATE
</filesMatch>
</ifModule>
RewriteRule .*\.(jpe?g|gif|png|bmp)$ - [F]
\.(jpe?g|gif|png|bmp)$ RewriteRule ^(.*)$ http://example.net/$1 [R=301]
RewriteRule (.*) http://example.net/$1 [R=301,L] RewriteRule ^([^.]+\.html). http://www.example.com/$1 [R=301,L] http://example.net/index.html/that returns a 404 error.
Here, conversely, there's no need for anchors. By default a Regular Expression will start as soon as it can and go on as long as it can:
RewriteRule (.*) http://example.net/$1 [R=301,L]
All redirects require the [L] flag. It isn't implied with [R] the way it is for [F] and certain other flags.
For instance, I am not sure what you mean by "literal periods".
So i do not know why Google brings up a page like
http://example.net/index.html/
that returns a 404 error.
<url>
<loc>http://example.net/</loc>
<lastmod>2014-02-20T12:24:06+00:00</lastmod>
</url>
www.example.com www.example.com/ blahblah/index.html/ index.html index.html/ RewriteRule ^([^.]+\.html). http://www.example.com/$1 [R=301,L] RewriteRule \.html. - [F] \.html. #4a index redirect
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html
RewriteRule ^(([^/]+/)*)index\.html http://example.com/$1 [R=301,L
#4b domain-name canonicalization redirect
RewriteCond %{HTTP_HOST} !^(example\.net)?$ [NC]
RewriteRule ^(.*)$ http://example.net/$1 [R=301]
#4c index/ redirect
RewriteRule ^([^.]+\.html). http://www.example.com/$1 [R=301,L]
#4a index redirect
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html
RewriteRule ^(([^/]+/)*)index\.html http://example.com/$1 [R=301,L
#4c index/ redirect
RewriteRule ^([^.]+\.html). http://example.com/$1 [R=301,L]
#4b domain-name canonicalization redirect
RewriteCond %{HTTP_HOST} !^(example\.net)?$ [NC]
RewriteRule ^(.*)$ http://example.net/$1 [R=301]