Mobile app version of vmapp.org
Login or Join
Margaret670

: Is my .htaccess rule creating an infinite loop? Whenever I type a made up address that includes a directory index it removes it. The problem is when the the address includes a forbidden subdirectory.

@Margaret670

Posted in: #Apache #Htaccess #ModRewrite

Whenever I type a made up address that includes a directory index it removes it. The problem is when the the address includes a forbidden subdirectory. It reduces itself until it hits forbidden. How do I get it to redirect to the homepage instead of reducing itself?

Options -Indexes +FollowSymlinks -MultiViews
RewriteEngine on

DirectoryIndex index.htm index.html index.php

# REDIRECT www to non-wwww
# Set Canonical URL
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ www.%{HTTP_HOST}/ [R=301,L]

# REMOVE Directory Index From URL
RewriteRule ^([a-zA-Z0-9_-]+/)?index.(htm?|html?)$ / [R=301,L]

# Custom Error Documents
ErrorDocument 404 /errors/404_notfound.htm

10% popularity Vote Up Vote Down


Login to follow query

More posts by @Margaret670

0 Comments

Sorted by latest first Latest Oldest Best

Back to top | Use Dark Theme