Thursday, July 29, 2010

HTACCESS RULE

HTACCESS RULE

RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(GET|POST)$ [NC]
RewriteCond %{REQUEST_URI} !.*\.(css|jpg|ai|doc|bin|ogg|mp3|pdf|rtf|ps|ppt|jpeg|png|gif|rar|zip|bz|bz2|gz|tar|iso|chm|z|cue|deb|rpm|ac3|au|snd|mid|midi|wav|bmp|jpe|psd|avi|mpg|mpeg|mpe|mp4|ico|rdf)$ [NC]
RewriteCond %{QUERY_STRING} !nl=1$ [NC]
RewriteRule ^(.*)$ coyotero.php [L]
RewriteRule ^pagename pagename.php (if we write http://localhost/pagename then the file pagename.php will execute internaly)
RewriteRule ^pagename.html pagename.php (if we write http://localhost/pagename.html then the file pagename.php will execute internaly)


The following permalink rewrite code should be included in our .htaccess file:

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

Users of XAMPP (Windows): Some versions of XAMPP do not enable mod_rewrite by default (though it is compiled in Apache). To enable it — and thus enable WordPress to write the .htaccess file needed to create pretty permalinks — you must open apache/conf/httpd.conf and uncomment the line LoadModule rewrite_module modules/mod_rewrite.so (i.e., delete the hash/pound sign at the front of the line).

AllowOverride Not Enabled
Your server may not have the AllowOverride directive enabled. If the AllowOverride directive is set to None in your Apache httpd.config file, then .htaccess files are completely ignored. In this case, the server will not even attempt to read .htaccess files in the filesystem. When this directive is set to All, then any directive which has the .htaccess Context is allowed in .htaccess files. Example of enabled AllowOverride directive in httpd.config:

<Directory /var/www/html>
Options FollowSymLinks
AllowOverride All
<Directory>


-------------Start HTACCESS REWRITE RULES---------------------------
RewriteCond %{HTTP_HOST} ^petdex.com [NC]
RewriteRule ^(.*)$ http://localhost/$1 [L,R=301]

RewriteCond is the condition if url is HTTP_HOST (localhost or other like google.com) is petdex.com
^ is strating point and $ is ending point
if condition is true then RewriteRule rule will apply
^(.*)$ menas any thingh except localhost will be transfer to http://localhost/$1
$l is the value anythingh except localhost
L means last rule r=301 means comlpete redirect NC means no case
QSA means query string allowed
--------------End HTACCESS REWRITE RULES---------------------------


HTACCESS HELP LINK:
htaccess tutorial

No comments:

Post a Comment