Showing posts with label PHP configuration. Show all posts
Showing posts with label PHP configuration. Show all posts

how to enable mod_rewrite / mod rewrite module

wampmanager -> Apache -> Apache modules -> and click the line [rewrite_module] if it is not ticked
You may have to scroll the menu down to find rewrite_module

.htaccess

Advantage/ Uses of htaccess?
1)   Authorization, authentication: .htaccess files are often used to specify the security restrictions for the particular directory, hence the filename "access". The .htaccess file is often accompanied by an .htpasswd file which stores valid usernames and their passwords.
  
2)   Customized error responses: Changing the page that is shown when a server-side error occurs, for example HTTP 404 Not Found.
Example : ErrorDocument 404 /notfound.html
3) Rewriting URLs: Servers often use .htaccess to rewrite "ugly" URLs to shorter and prettier ones.
4)   Cache Control: .htaccess files allow a server to control User agent caching used by web browsers to reduce bandwidth usage, server load, and perceived lag.

htaccess redirect

301 Redirect
RewriteRule ^services-area/danderong$ http://www.metrobinhire.com.au/services-area/dandenong [L,R=301]

Joomla 301 redirection
Redirect 301 /services-area/danderong http://www.metrobinhire.com.au/services-area/dandenong

301 Redirect with Query String
//Link: http://www.southamstudios.com/index.php?main_page=page&id=11
//htaccess

RewriteCond %{HTTP_HOST} ^southamstudios.com$ [NC]

RewriteCond %{QUERY_STRING} ^main_page=page&id=41$ [NC]

RewriteRule ^(.*)$ https://mq.southamstudios.com/? [R=301,L]
OR
RewriteCond %{QUERY_STRING} ^main_page=page&id=41$ [NC]

RewriteRule ^(.*)$ https://mq.southamstudios.com/? [R=301,L]

HTTP to HTTPS Redirect


RewriteCond %{HTTPS} off

RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]

RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

RewriteCond %{HTTPS} off

RewriteCond %{HTTP_HOST} !^www\.(.+)$ [NC]

RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTPS} on

RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]

RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

www to non-www

RewriteCond %{HTTP_HOST} ^www.holmesglen.southamstudios.com$ [NC]

RewriteRule ^(.*)$ https://holmesglen.southamstudios.com/$1 [R=301,L]

non-www to www

RewriteCond %{HTTP_HOST} ^shappere.com.au$

RewriteRule ^(.*)$ "http\:\/\/www\.shappere\.com\.au\/$1" [R=301,L]

php.ini


Enable virtual host

step 1:
first include vhost file in to httpd.conf by uncommenting the following line:
Include conf/extra/httpd-vhosts.conf
step 2:
open c:/wamp/bin/apache/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "C:\Wamp\www\southamstudios_v3"
ServerName swinburne2.southam.com
ErrorLog "logs/southam.com-error.log"
CustomLog "logs/southam.com-access.log" common
</VirtualHost>
step 3: Restart apache service
step 4: do the host entry in 
C:\Windows\System32\drivers\etc
127.0.0.1       swinburne2.southam.com


<VirtualHost *:80>
        ServerName gradpak.com
ServerAlias www.gradpak.com
ServerAlias organization.gradpak.com
        ServerAdmin support@gradpak.com
        DocumentRoot  "C:\wamp\www\gradpak"
        <Directory  "C:\wamp\www\gradpak">
        Options FollowSymLinks
                Allow from all
                AllowOverride All
                Order allow,deny
                Require all granted
        </Directory>
</VirtualHost>

Enables caching via .htaccess

http://samaxes.com/2009/01/more-on-compressing-and-caching-your-site-with-htaccess/ 

When we upload a site in KewellCahill, can you please add these lines at the end of the .htaccess file. This enables caching.


<filesMatch "\.(flv|FLV|gif|GIF|jpg|JPG|jpeg|JPEG|png|PNG|ico|ICO|swf|SWF)$">
    Header set Cache-Control "max-age=7257600"
</filesMatch>
<filesMatch "\.(js|JS|css|CSS|pdf|PDF|txt|TXT)$">
    Header set Cache-Control "max-age=604800"
</filesMatch>
<filesMatch "\.(html|HTML|htm|HTM)$">
    Header set Cache-Control "max-age=600"
</filesMatch>
<filesMatch "\.(pl|PL|php|PHP|cgi|CGI|spl|SPL)$">
    Header unset Cache-Control
    Header unset Expires
    Header unset Last-Modified
    FileETag None
    Header unset Pragma
</filesMatch>


## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>

## EXPIRES CACHING ##