Forum Moderators: phranque
RewriteCond %{HTTP_HOST} ^domain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain\.com$
RewriteRule ^ugly-folder-name\/?(.*)$ "http\:\/\/www\.domain\.com" [R=301,L]
While the actual redirect works
"http\:\/\/www\.domain\.com"
I need to redirect the contents of an entire directory back to the home page of the website.
(which would essentially lead to 1000's of copies of my home page).
Redirect gone /folder-name/
ErrorDocument 410 default
And should I put this code in a separate .htaccess file inside the folder?
RewriteCond %{HTTP_HOST} ^domain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain\.com$
RewriteRule ^ugly-folder-name\/?(.*)$ "http\:\/\/www\.domain\.com" [R=301,L]
the sort of carbuncle
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com
The only reason the www. is optional is that this rule comes before the domain-name-canonicalization redirect. Otherwise you'd specify one or the other. No need for closing anchor except in the rare case where you've also got an exact-same-name.com.tld in the same place. the sort of carbuncle
RewriteCond %{HTTP_HOST} ^domain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain\.com$
RewriteRule ^ugly-folder-name\/?(.*)$ "http\:\/\/www\.domain\.com" [R=301,L]
This looks like the sort of carbuncle that cPanel generates?
RewriteOptions inherit
Options +Includes
RewriteEngine on
# -FrontPage-
# Re-write non-www to www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain.com
RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L]
IndexIgnore .htaccess */.?* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
#The next line modified by DenyIP
order allow,deny
#The next line modified by DenyIP
#deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName www.mydomain.com
AuthUserFile /home/bigsky/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/bigsky/public_html/_vti_pvt/service.grp
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
# Begin Cache Control
Header unset Pragma
FileETag None
Header unset ETag
# cache images/pdf/css docs for 1 Month
<FilesMatch "\.(ico|pdf|jpg|jpeg|png|gif|svg|css)$">
Header set Cache-Control "max-age=2629000, public, must-revalidate"
Header unset Last-Modified
</FilesMatch>
# cache html/htm/xml/txt diles for 2 Days
<FilesMatch "\.(xml|txt|xsl|js|woff)$">
Header set Cache-Control "max-age=172800, must-revalidate"
</FilesMatch>
#End Cache Control
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/htm
AddOutputFilterByType DEFLATE text/shtm
AddOutputFilterByType DEFLATE text/php
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
#End Compression
(------ A Whole Pile of 301 Redirects Go Here ---------)
(and the last line of my .htaccess file is below)
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$
RewriteRule ^phpbb2\/?(.*)$ "http\:\/\/www\.mydomain\.com\/xen\/" [R=301,L] (
ErrorDocument 410 /missing.html RewriteRule ^old-discontinued-directory - [G]
after access control, before any existing redirects. The [G] flag means 410, like [F] means 403. It carries an implied L. No need for a closing anchor; you're serving up an all-encompassing 410 for everything in the directory.