I have the following code in my .htaccess
My webhost has asked me to add the following snippet for automatic https redirects
When I Use the below code, it results into my webdirectory names insomniac being pushed in the url redirects
Kindly review the code and let me know what I should do to avoid insomniacs being pushed inside the url.
Code:
Options +FollowSymLinks Options -MultiViews RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ RewriteRule ^index\.php$ http://sitename.com/ [R=301,L] RewriteCond %{HTTP_HOST} ^www.sitename.com$ [NC] RewriteRule ^(.*)$ http://sitename.com/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^sitename.org$ [OR] RewriteCond %{HTTP_HOST} ^www.sitename.org$ RewriteRule (.*)$ http://sitename.com/$1 [R=301,L] RewriteRule ^forum/topiclists/([^/]*)\.php$ /forum/topiclists.php?page=$1 [L] RewriteRule ^bloglists/([^/]*)\.php$ /bloglists.php?page=$1 [L] RewriteRule ^forum/cat([^/]*)/([^/]*)\.php$ /forum/forum-category.php?cid=$1&name=$2 [L] RewriteRule ^forum/subcat([^/]*)/([^/]*)\.php$ /forum/mobile-forum.php?fid=$1&name=$2 [L] RewriteRule ^forum/subcat([^/]*)/([^/]*)/([^/]*)\.php$ /forum/mobile-forum.php?fid=$1&name=$2&page=$3 [L] RewriteRule ^forum/topic([^/]*)/([^/]*)\.php$ /forum/mobile-forum-topic.php?tid=$1&name=$2 [L] RewriteRule ^forum/topic([^/]*)/([^/]*)/([^/]*)\.php$ /forum/mobile-forum-topic.php?tid=$1&name=$2&page=$3 [L] RewriteRule ^forum/topic([^/]*)/([^/]*)/go/([^/]*)\.php$ /forum/mobile-forum-topic.php?tid=$1&name=$2&go=$3 [L] RewriteRule ^mobileblog/([^_]*)_([^_]*)\.php$ /mobile-blogsx.php?note=$1&nameit=$2 [L] RewriteRule ^mobile-blogs/([^/]*)\.php$ /mobile-blogs.php?page=$1 [L] RewriteRule ^forum/index\.php$ http://sitename.com/forum/ [R=301,L] ErrorDocument 404 /404.php ErrorDocument 500 /500.php AddType audio/x-midi .mid AddType audio/mpeg3 .mp3 AddType image/gif .gif .GIF AddType image/jpeg .jpeg .jpg .jpe .JPG AddType text/x-vcard .vcf AddType video/x-msvideo .avi .AVI .xvid AddType video/3gpp .3gp .3GP AddType video/mp4 .mp4 AddType audio/aac .m4r .M4R AddType video/vnd.mpegurl .m4u .mxu AddType text/vnd.sun.j2me.app-descriptor .jad .JAD AddType application/vnd.android.package-archive .apk .APK AddType application/vnd.symbian.install .sis .SIS AddType x-epoc/x-sisx-app .sisx .SISX AddType application/java-archive .jar .JAR AddType application/x-zip-compressed .zip .ZIP AddType application/x-rar-compressed .rar .RAR AddType application/txt .vbm AddType application/octet-stream .ipa AddType video/quicktime .mov AddType video/mpeg .mpg .mpeg AddType application/vnd.rn-realmedia-vbr .rmvb AddType video/x-ms-wmv .wmv AddType video/divx .divx AddType application/vnd.rn-realmedia .rm AddType application/octet-stream .ipd .alx .rem .rfi .app AddType text/plain .txt .cod AddType image/png .png AddType text/xml .xml AddType application/rss+xml .rss AddType application/pdf .pdf AddType application/vnd.openxmlformats .docx AddType application/msword .doc AddType application/x-ms-dos-executable .exe AddType application/x-font-ttf .ttf AddType application/octet-stream .ttc AddType application/octet-stream .fon <ifModule mod_expires.c> ExpiresActive On ExpiresDefault "access plus 1 hour" ExpiresByType text/html "access plus 15 seconds" ExpiresByType image/gif "access plus 2592000 seconds" ExpiresByType image/jpeg "access plus 2592000 seconds" ExpiresByType image/png "access plus 2592000 seconds" ExpiresByType text/css "access plus 604800 seconds" </ifModule> <IfModule mod_deflate.c> <FilesMatch "\.(js|css)$"> SetOutputFilter DEFLATE </FilesMatch> </IfModule> <FilesMatch "\.(ico|pdf|flv)$"> Header set Cache-Control "max-age=29030400, public" </FilesMatch> <FilesMatch "\.(jpg|jpeg|png|gif|swf)$"> Header set Cache-Control "max-age=29030400, public" </FilesMatch> <FilesMatch "\.(xml|css|js)$"> Header set Cache-Control "max-age=29030400, proxy-revalidate" </FilesMatch> <FilesMatch "\.(html|txt|htm|php)$"> Header set Cache-Control "max-age=60, private, proxy-mustcheck" </FilesMatch>
Code:
RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Code:
Options +FollowSymLinks Options -MultiViews RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ RewriteRule ^index\.php$ http://sitename.com/ [R=301,L] RewriteCond %{HTTP_HOST} ^www.sitename.com$ [NC] RewriteRule ^(.*)$ http://sitename.com/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^sitename.org$ [OR] RewriteCond %{HTTP_HOST} ^www.sitename.org$ RewriteRule (.*)$ http://sitename.com/$1 [R=301,L] RewriteRule ^forum/topiclists/([^/]*)\.php$ /forum/topiclists.php?page=$1 [L] RewriteRule ^bloglists/([^/]*)\.php$ /bloglists.php?page=$1 [L] RewriteRule ^forum/cat([^/]*)/([^/]*)\.php$ /forum/forum-category.php?cid=$1&name=$2 [L] RewriteRule ^forum/subcat([^/]*)/([^/]*)\.php$ /forum/mobile-forum.php?fid=$1&name=$2 [L] RewriteRule ^forum/subcat([^/]*)/([^/]*)/([^/]*)\.php$ /forum/mobile-forum.php?fid=$1&name=$2&page=$3 [L] RewriteRule ^forum/topic([^/]*)/([^/]*)\.php$ /forum/mobile-forum-topic.php?tid=$1&name=$2 [L] RewriteRule ^forum/topic([^/]*)/([^/]*)/([^/]*)\.php$ /forum/mobile-forum-topic.php?tid=$1&name=$2&page=$3 [L] RewriteRule ^forum/topic([^/]*)/([^/]*)/go/([^/]*)\.php$ /forum/mobile-forum-topic.php?tid=$1&name=$2&go=$3 [L] RewriteRule ^mobileblog/([^_]*)_([^_]*)\.php$ /mobile-blogsx.php?note=$1&nameit=$2 [L] RewriteRule ^mobile-blogs/([^/]*)\.php$ /mobile-blogs.php?page=$1 [L] RewriteRule ^forum/index\.php$ http://sitename.com/forum/ [R=301,L] ErrorDocument 404 /404.php ErrorDocument 500 /500.php AddType audio/x-midi .mid AddType audio/mpeg3 .mp3 AddType image/gif .gif .GIF AddType image/jpeg .jpeg .jpg .jpe .JPG AddType text/x-vcard .vcf AddType video/x-msvideo .avi .AVI .xvid AddType video/3gpp .3gp .3GP AddType video/mp4 .mp4 AddType audio/aac .m4r .M4R AddType video/vnd.mpegurl .m4u .mxu AddType text/vnd.sun.j2me.app-descriptor .jad .JAD AddType application/vnd.android.package-archive .apk .APK AddType application/vnd.symbian.install .sis .SIS AddType x-epoc/x-sisx-app .sisx .SISX AddType application/java-archive .jar .JAR AddType application/x-zip-compressed .zip .ZIP AddType application/x-rar-compressed .rar .RAR AddType application/txt .vbm AddType application/octet-stream .ipa AddType video/quicktime .mov AddType video/mpeg .mpg .mpeg AddType application/vnd.rn-realmedia-vbr .rmvb AddType video/x-ms-wmv .wmv AddType video/divx .divx AddType application/vnd.rn-realmedia .rm AddType application/octet-stream .ipd .alx .rem .rfi .app AddType text/plain .txt .cod AddType image/png .png AddType text/xml .xml AddType application/rss+xml .rss AddType application/pdf .pdf AddType application/vnd.openxmlformats .docx AddType application/msword .doc AddType application/x-ms-dos-executable .exe AddType application/x-font-ttf .ttf AddType application/octet-stream .ttc AddType application/octet-stream .fon <ifModule mod_expires.c> ExpiresActive On ExpiresDefault "access plus 1 hour" ExpiresByType text/html "access plus 15 seconds" ExpiresByType image/gif "access plus 2592000 seconds" ExpiresByType image/jpeg "access plus 2592000 seconds" ExpiresByType image/png "access plus 2592000 seconds" ExpiresByType text/css "access plus 604800 seconds" </ifModule> <IfModule mod_deflate.c> <FilesMatch "\.(js|css)$"> SetOutputFilter DEFLATE </FilesMatch> </IfModule> <FilesMatch "\.(ico|pdf|flv)$"> Header set Cache-Control "max-age=29030400, public" </FilesMatch> <FilesMatch "\.(jpg|jpeg|png|gif|swf)$"> Header set Cache-Control "max-age=29030400, public" </FilesMatch> <FilesMatch "\.(xml|css|js)$"> Header set Cache-Control "max-age=29030400, proxy-revalidate" </FilesMatch> <FilesMatch "\.(html|txt|htm|php)$"> Header set Cache-Control "max-age=60, private, proxy-mustcheck" </FilesMatch>
Comment