I'm having a problem using this rewrite:
RewriteCond %{HTTP_HOST} www.example.com$
RewriteRule ^(.*)$ http://example.com$1 [R=301,L]
to remove the www url
But the return is a url without a trailing slash. For example: example.com/subfolder which supposedly has a url of example.com/subfolder, but the result is example.comsubfolder whch breaks the url. Anyone could help me solving this? Many thanks!
EDIT: here's my whole .htaccess
Header unset Pragma
FileETag None
Header unset ETag
# 1 YEAR
<FilesMatch "\.(ico|pdf|flv)$">
Header set Cache-Control "max-age=29030400, public"
</FilesMatch>
# 1 WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
# 2 DAYS 172800
<FilesMatch "\.(xml|txt|css|js)$">
Header set Cache-Control "max-age=604800, proxy-revalidate"
</FilesMatch>
# 1 MIN
<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=60, private, proxy-revalidate"
</FilesMatch>
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Expires "Thu, 15 Dec 2011 20:00:00 GMT"
</FilesMatch>
RewriteEngine On
RewriteCond %{QUERY_STRING} (^|\?)f=([0-9]+)&t=([0-9]+)($|&)
RewriteRule ^viewtopic\.php$ /index.php?threads/%3/ [R=301,L]
RewriteCond %{QUERY_STRING} (^|\?)f=([0-9]+)($|&)
RewriteRule ^viewforum\.php$ /index.php?forums/%2/ [R=301,L]
RewriteCond %{HTTP_HOST} www.example.com$
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
# Use PHP5.4 Single php.ini as default
AddHandler application/x-httpd-php54s .php
#
# Uncomment the statement below if you want to make use of
# HTTP authentication and it does not already work.
# This could be required if you are for example using PHP via Apache CGI.
#
## EXPIRES CACHING ##
<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default directive
ExpiresDefault "access plus 1 month"
# My favicon
ExpiresByType image/x-icon "access plus 1 yearâ€
# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
# CSS
ExpiresByType text/css "access 1 monthâ€
# Javascript
ExpiresByType application/javascript "access plus 1 year"
</IfModule>
## EXPIRES CACHING ##
#<IfModule mod_rewrite.c>
#RewriteEngine on
#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#</IfModule>
<Files "config.php">
Order Allow,Deny
Deny from All
</Files>
<Files "common.php">
Order Allow,Deny
Deny from All
</Files>
DirectoryIndex portal.php index.php index.html index.htm
RewriteCond %{HTTP_REFERER} !^http://example.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://example.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.example.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.example.com$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]
# Start CloudFlare:example.com rewrite. Do not Edit
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# End CloudFlare rewrite.
# Mod_security can interfere with uploading of content such as attachments. If you
# cannot attach files, remove the "#" from the lines below.
#<IfModule mod_security.c>
# SecFilterEngine Off
# SecFilterScanPOST Off
#</IfModule>
ErrorDocument 401 default
ErrorDocument 403 default
ErrorDocument 404 default
ErrorDocument 405 default
ErrorDocument 406 default
ErrorDocument 500 default
ErrorDocument 501 default
ErrorDocument 503 default
<IfModule mod_rewrite.c>
# If you are having problems with the rewrite rules, remove the "#" from the
# line that begins "RewriteBase" below. You will also have to change the path
# This line may be needed to enable WebDAV editing with PHP as a CGI.
#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
</IfModule>
Related
beginner here :). So I have a wordpress website on which I added some of my own database tables and php & sql scripts. Users can login on my website (independently of wordpress) and then add content into my database tables, which is then shown on the website.
I have just switched to HTTPS with a certificate from Let's encrypt and I have a big problem. The URL's to my pages (those which are NOT wordpress) are not working anymore and are showing a 404 error. I spent a week trying to fix the issue but I just can't do it with my limited skills. Here is some info below.
The script which is generating the pages has the following code:
$testurl = 'https://www.example.com/test-pages/'.sanitize_title($row['c2']).'-'.$row['id'];
In .htaccess, I have the following line:
RewriteRule ^test-pages/[_a-z0-9-]+\-{1}([0-9]+)$ /test-pages?id=$1 [P]
These two should properly rewrite the urls, right (though I'm not sure where $testurl is called, the line of code is just sitting there in my script)? The particular lines of code were written by somebody else, so I'm not sure if I'm missing something, but they worked for years with plain old http!
I think I took the proper steps to set up https and all the wordpress pages are working.
Also, interestingly, if I try to access the pages with http, it redirects to https://www.example.com/test-pages?id= , which I guess is the standard url created out of the database, which the scripts presented above used to overwrite. And it shows the page fine. So I can make things work linking to pages in that way, but I don't want that.
At this point I have no idea what to do, normally I manage to overcome such issues, but not this time. I searched stackoverflow for solutions too, but found nothing to make sense for me. Any ideas? Is the problem here, or somewhere else? Hopefully I managed to explain the issue properly and somewhat coherently. Thank you!
EDIT: I added the htaccess file. I don't know exactly what more I should add.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.maindomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.maindomain\.com$
RewriteCond %{HTTPS} off
RewriteRule ^/?$ "https\:\/\/example\.com" [R=301,L]
RewriteRule ^test-pages/[_a-z0-9-]+\-{1}([0-9]+)$ /test-pages?id=$1 [P]
RewriteRule ^test-profiles/[_a-z0-9-]+\-{1}([0-9]+)$ /test-profiles?id=$1 [P]
# BEGIN rlrssslReallySimpleSSL rsssl_version[3.3.5]
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on [NC]
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
# END rlrssslReallySimpleSSL
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 month"
</IfModule>
## EXPIRES CACHING ##
<Files 403.shtml>
order allow,deny
allow from all
</Files>
# Wordfence WAF
<Files ".user.ini">
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>
</Files>
# END Wordfence WAF
<files wp-login.php>
order deny,allow
deny from all
allow from **.***.**.**
</files>
ErrorDocument 401 default
ErrorDocument 403 default
ErrorDocument 404 default
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php74” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php74 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit```
I have a .htaccess file which is rewriting all of my urls from path/to/file.php to just path/to/file.
I had this working locally on WAMP, and it also worked on a domain hosted by blacknight.
However, we are moving to Google Cloud Platform using Debian 9, and it does not work here at all. If I do not include the .php extension I will get a 404 error.
Below is my full .htaccess file:
Options -MultiViews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^post/([^\/]+)/?$ post.php?url=$1 [L,NC,QSA]
RewriteRule ^payment/([^\/]+)/?$ payment.php?sub=$1 [L,NC,QSA]
RewriteRule ^player/([^\/]+)/?$ player.php?id=$1 [L,NC,QSA]
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 week"
ExpiresByType image/jpeg "access 1 week"
ExpiresByType image/gif "access 1 week"
ExpiresByType image/png "access 1 week"
ExpiresByType text/css "access 1 hour"
ExpiresByType text/x-javascript "access 1 hour"
</IfModule>
<IfModule mod_headers.c>
Header set Connection keep-alive
<filesmatch "\.(ico|gif|jpg|jpeg|png)$">
Header set Cache-Control "max-age=604800, public"
</filesmatch>
<filesmatch "\.(css)$">
Header set Cache-Control "max-age=3600, private"
</filesmatch>
<filesmatch "\.(js)$">
Header set Cache-Control "max-age=3600, private"
</filesmatch>
<filesMatch "\.(x?html?|php)$">
Header set Cache-Control "max-age=0, private, must-revalidate"
</filesMatch>
</IfModule>
What can I do to resolve this or is there another way of rewriting URLs in Google Cloud Platform?
If your Apache server is enabled you should check if the AllowOverride directive is enabled as well (set to "All" or allowing specific options). Otherwise Apache will not consider the directives that you put there.
This should usually be placed in your Virtual server config file or the main one.
Here is an example:
<Directory "/path/from/where/you/serve/files">
AllowOverride All
</Directory>
More info:
https://httpd.apache.org/docs/2.4/mod/core.html#allowoverride
My main website is:
http://sandybeachit.co.uk
I have a wordpress site setup at my addon-domain:
[http://imadeitviral.com][1]
The wordpress site is in:
/hosting/imadeitviral
The above address can be found here on the primary site under sandybeachit.co.uk/hosting/imadeitviral/
I have got the site url and home set to "http:// imadeitviral.com" (without the space between "http:// and madeitviral.com"
But when you go imadeitviral.com the site attempts to load my primary site at sandybeachit.co.uk except the site does not load correctly, you can try it and your see what i mean.
If i set the wordpress site url and home to pointing to "sandybeachit.co.uk/hosting/imadeitviral" the site will load fine, so i know i have got something wrong, but i can not figure out what.
I have tried removing the .htaccess file in my main domain and editing it so i an sure its not that is the problem as well as the .htaccess file in the wordpress folder.
I did the install via Site Software Softaculous Apps Installer
Can i get some pointers as to what i have done wrong or missed ?
Thanks
HTACCESS FILE IN WORDPRESS DIRECTORY:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /hosting/imadeitviral/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /hosting/imadeitviral/index.php [L]
</IfModule>
# END WordPress
HTACCESS FILE IN MAIN DIRECTORY:
RewriteCond %{HTTP_HOST} ^(www\.)?imadeitviral\.com
RewriteRule .* - [L]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)/$ /$1.php [L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule .*[^/]$ /$0/ [L,R=301]
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
#RULES ADDED AFTER 14TH JANUARY 2017
# Set Timezone
<IfModule !fcgid_module>
php_value date.timezone "Europe/London"
</IfModule>
# Disable directory browsing
Options All -Indexes
### Security - Disable HTTP Track and Trace
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
# STRONG HTACCESS PROTECTION
<Files ~ "^.*\.([Hh][Tt][Aa])">
order allow,deny
deny from all
satisfy all
</Files>
#DENY ACCESS - START
<FilesMatch "config.php|\.tpl$">
Order allow,deny
Deny from all
</FilesMatch>
#DENY ACCESS - END
# One year for image files
<filesMatch ".(jpg|jpeg|png|gif|ico)$">
Header set Cache-Control "max-age=31536000, public"
</filesMatch>
# One month for css and js
<filesMatch ".(css|js)$">
Header set Cache-Control "max-age=2628000, public"
</filesMatch>
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)(\.gz)?$">
Header set Expires "Thu, 15 Apr 2012 20:00:00 GMT"
Header unset ETag
FileETag None
</FilesMatch>
# 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
# GZIP BEGIN - COMPRESS - .CSS .JS .HTML .XHTML .PHP .TXT
#Gzip
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x- javascript application/javascript
</ifmodule>
#End Gzip
<IfModule mod_deflate.c>
#The following line is enough for .js and .css
AddOutputFilter DEFLATE js css
#The following line also enables compression by file content type, for the following list of Content-Type:s
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml
#The following lines are to avoid bugs with some browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>
<ifModule mod_headers.c>
Header unset Vary
Header set Vary "Accept-Encoding, X-HTTP-Method-Override, X-Forwarded-For, Remote-Address, X-Real-IP, X-Forwarded-Proto, X-Forwarded-Host, X-Forwarded-Port, X-Forwarded-Server"
</ifModule>
After a little more testing:
What i am finding is if i goto:
imadeitviral.com/
The site loads
As soon as i go into:
imadeitviral.com/wp-admin
after a short while the site times out to a 404 with the message:
"Not Found
The requested URL /wp-admin/plugins.php was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."
i have the following folder structure on my hosting (it is a shared one)
public_html
|
|
|--- website (contains CodeIgniter application)
|--- otherapp (another CodeIgniter application)
|--- moreapp (yet another web application)
What i want to do is that when ever a user type my domain (http://example.com) it should loads the content within the 'website' folder.
While a user type http://otherapp.example.com it should open what ever index.php reside within the 'otherapp' folder.
First i tried this (and saved it in the root folder[public_html]):
Redirect /index.php http://example.com/otherapp/index.php and it pretty much screwed the URL and links.
Then i tried this (a brute copy paste from Joomla htaccess):
## Can be commented out if causes errors, see notes above.
Options +FollowSymLinks
## Mod_rewrite in use.
RewriteEngine On
# Block out any script trying to base64_encode data within the URL.
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Block out any script that includes a <script> tag in URL.
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL.
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL.
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Return 403 Forbidden header and show the content of the root homepage
RewriteRule .* index.php [F]
##
# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root).
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index\.php
# and the request is for something within the component folder,
# or for the site root, or for an extensionless URL, or the
# requested URL ends with one of the listed extensions
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC]
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]
Within otherapps folder (which is the codeigniter application i have this specific .htaccess)
which:
1. To get rid of index.php ending trail
2. Speed up web page load by doing some caching
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
#
# associate .js with "text/javascript" type (if not present in mime.conf)
#
AddType text/javascript .js
#
# configure mod_expires
#
# URL: http://httpd.apache.org/docs/2.2/mod/mod_expires.html
#
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType image/x-icon "access plus 2692000 seconds"
ExpiresByType image/jpeg "access plus 2692000 seconds"
ExpiresByType image/png "access plus 2692000 seconds"
ExpiresByType image/gif "access plus 2692000 seconds"
ExpiresByType application/x-shockwave-flash "access plus 2692000 seconds"
ExpiresByType text/css "access plus 2692000 seconds"
ExpiresByType text/javascript "access plus 2692000 seconds"
ExpiresByType application/x-javascript "access plus 2692000 seconds"
ExpiresByType text/html "access plus 600 seconds"
ExpiresByType application/xhtml+xml "access plus 600 seconds"
</IfModule>
#
# configure mod_headers
#
# URL: http://httpd.apache.org/docs/2.2/mod/mod_headers.html
#
<IfModule mod_headers.c>
<FilesMatch "\\.(ico|jpe?g|png|gif|swf|css|js)$">
Header set Cache-Control "max-age=2692000, public"
Header set Last-Modified "Mon, 31 May 2014 00:00:00 GMT"
</FilesMatch>
<FilesMatch "\\.(x?html?|php)$">
Header set Cache-Control "max-age=600, private, must-revalidate"
</FilesMatch>
Header set Connection keep-alive
</IfModule>
#Gzip
<ifmodule mod_deflate.c>
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-javascript application/x-httpd-php
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip
Header append Vary User-Agent env=!dont-vary
</ifmodule>
#End Gzip
The problem that i am facing at the moment is that some links are not redirected properly. I am not sure how to explain the problem (i think it is too random).
Place this rule in root .htaccess:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule ^((?!website/).*)$ website/$1 [NC,L]
RewriteCond %{HTTP_HOST} ^otherapp\.example\.com$ [NC]
RewriteRule ^((?!otherapp/).*)$ otherapp/$1 [NC,L]
I was wondering how to redirect a link such as www.example.com/forum/index.php to www.example.com/forum/. I have been having trouble, I tried looking it up on Google but none of the solutions are working for me. I have WordPress installed in my root directory, along with phpbb forum software in my forum directory.
My forum sub directory .htaccess:
#
# Uncomment the statement below if you want to make use of
# HTTP authentication and it does not already work.
# This could be required if you are for example using PHP via Apache CGI.
#
#<IfModule mod_rewrite.c>
#RewriteEngine on
#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#</IfModule>
<Files "config.php">
Order Allow,Deny
Deny from All
</Files>
<Files "common.php">
Order Allow,Deny
Deny from All
</Files>
and this is my root folder .htaccess:
# BEGIN W3TC Browser Cache
<IfModule mod_deflate.c>
<IfModule mod_setenvif.c>
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
</IfModule>
<IfModule mod_headers.c>
Header append Vary User-Agent env=!dont-vary
</IfModule>
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon
</IfModule>
</IfModule>
<FilesMatch "\.(css|js|htc|CSS|JS|HTC)$">
FileETag None
<IfModule mod_headers.c>
Header set X-Powered-By "W3 Total Cache/0.9.2.4"
</IfModule>
</FilesMatch>
<FilesMatch "\.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|HTML|HTM|RTF|RTX|SVG|SVGZ|TXT|XSD|XSL|XML)$">
FileETag None
<IfModule mod_headers.c>
Header set X-Powered-By "W3 Total Cache/0.9.2.4"
</IfModule>
</FilesMatch>
<FilesMatch "\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip|ASF|ASX|WAX|WMV|WMX|AVI|BMP|CLASS|DIVX|DOC|DOCX|EOT|EXE|GIF|GZ|GZIP|ICO|JPG|JPEG|JPE|MDB|MID|MIDI|MOV|QT|MP3|M4A|MP4|M4V|MPEG|MPG|MPE|MPP|OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|PNG|POT|PPS|PPT|PPTX|RA|RAM|SVG|SVGZ|SWF|TAR|TIF|TIFF|TTF|TTC|WAV|WMA|WRI|XLA|XLS|XLSX|XLT|XLW|ZIP)$">
FileETag None
<IfModule mod_headers.c>
Header set X-Powered-By "W3 Total Cache/0.9.2.4"
</IfModule>
</FilesMatch>
# END W3TC Browser Cache
# BEGIN W3TC Page Cache core
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.*\/)?w3tc_rewrite_test$ $1?w3tc_rewrite_test=1 [L]
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteRule .* - [E=W3TC_ENC:_gzip]
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{QUERY_STRING} =""
RewriteCond %{HTTP_HOST} = site.com
RewriteCond %{REQUEST_URI} \/$ [OR]
RewriteCond %{REQUEST_URI} (sitemap(_index)?\.xml(\.gz)?|[a-z0-9_\-]+-sitemap([0-9]+)?\.xml(\.gz)?) [NC]
RewriteCond %{REQUEST_URI} !(\/wp-admin\/|\/xmlrpc.php|\/wp-(app|cron|login|register|mail)\.php|\/feed\/|wp-.*\.php|index\.php) [NC,OR]
RewriteCond %{REQUEST_URI} (wp-comments-popup\.php|wp-links-opml\.php|wp-locations\.php) [NC]
RewriteCond %{HTTP_COOKIE} !(comment_author|wp-postpass|wordpress_\[a-f0-9\]\+|wordpress_logged_in) [NC]
RewriteCond %{HTTP_USER_AGENT} !(W3\ Total\ Cache/0\.9\.2\.4) [NC]
RewriteCond "%{DOCUMENT_ROOT}/wp-content/w3tc/pgcache/%{REQUEST_URI}/_index%{ENV:W3TC_UA}%{ENV:W3TC_REF}%{ENV:W3TC_SSL}.html%{ENV:W3TC_ENC}" -f
RewriteRule .* "/wp-content/w3tc/pgcache/%{REQUEST_URI}/_index%{ENV:W3TC_UA}%{ENV:W3TC_REF}%{ENV:W3TC_SSL}.html%{ENV:W3TC_ENC}" [L]
</IfModule>
# END W3TC Page Cache core
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Google Webmaster Tools has been saying I have duplicate title tags because of these 2 urls, I can not seem to figure it out!
In .htaccess there are basically two things you can do regarding URLs.
Rewriting URLs
You can rewrite URLs internally. If the user visits example.com/forum/ you can rewrite the URL internally to use example.com/forum/index.php. The user will see example.com/forum in their address bar.
In an .htaccess file, this would be written as:
RewriteRule ^forum /forum/index.php [L]
RewriteRule indicates that it should rewrite the URL. ^forum matches the forum part in example.com/forum/ and /forum/index.php says that it should rewrite the URL to /forum/index.php. Last [L] means that if this RewriteRule matches, it should stop matching rules.
Redirecting URLs
You can redirect an URL too. This will send an header to the client to load a different page instead. If the user visits example.com/forum/index.php, you can rewrite it to example.com/forum and order the client that requested that to load that URL instead. The user will see example.com/forum in their address bar.
In an .htaccess file, this would be written as:
RewriteRule ^forum/index\.php /forum [R,L]
Again, RewriteRule tells that the URL should be rewritten, if it matches ^forum/index\.php (notice the escaped dot, because it is a regex, we do not want it to match every character). It will be rewritten to /forum. Last, we have the flags [R,L]. R stands for 'redirect' (by default a temporary redirect) and L stands again for 'if this rule matches, stop matching any further rules.
Documentation
The documentation about mod_rewrite can be found here.