Movatterモバイル変換


[0]ホーム

URL:


Imam Rosidi, profile picture
Uploaded byImam Rosidi
960 views

Htaccess file tutorial and tips

This document provides a tutorial on how to create and configure .htaccess files to modify the behavior of an Apache web server. It explains how to create friendly URLs, redirect domains and subdomains, disable directory listings, configure error pages, and more. The document provides code examples for common tasks like redirection, rewriting URLs, and hiding file extensions.

Embed presentation

Downloaded 24 times
11/23/13 Htaccess File Tutorial and Tips.www.9lessons.info/2013/11/htaccess-file-tutorial-and-tips.html 1/4After posting Understanding of Regular Expression article most of my readers are expectingAfter posting Understanding of Regular Expression article most of my readers are expecting.htaccess basics, and I did not find any useful article on Google first page results. Specially I.htaccess basics, and I did not find any useful article on Google first page results. Specially Ilove to writelove to write.htaccess.htaccess file, using this you can easily configure and redirect Apache Web Serverfile, using this you can easily configure and redirect Apache Web Serverfile system. This post will explain you how to create friendly URLs, sub domain directory re-file system. This post will explain you how to create friendly URLs, sub domain directory re-directions and many more.directions and many more.Download Script Live DemoNote: .htaccess file will be in hidden format, please change your folder and file settings to view thisfile.How to Create a .htaccess File?Open any text editor application and file save as with .htaccess name andenablemod_rewrite extension in php.ini file in Apache Web Server configurations.Default directory Listing
11/23/13 Htaccess File Tutorial and Tips.www.9lessons.info/2013/11/htaccess-file-tutorial-and-tips.html 2/4Disable directory ListingIf you want to disable folder files listing, include following code.# Disable Directory BrowsingOptions All -IndexesError PagesHere error page is redirecting to error.html.errorDocument 400 http://www.youwebsite.com/error.htmlerrorDocument 401 http://www.youwebsite.com/error.htmlerrorDocument 404 http://www.youwebsite.com/error.htmlerrorDocument 500 http://www.youwebsite.com/error.htmlRewriteEngine On it is turn on Rewrite Rules in Apache Server. if you want to turn off, just changethe value to off.RewriteEngine on
11/23/13 Htaccess File Tutorial and Tips.www.9lessons.info/2013/11/htaccess-file-tutorial-and-tips.html 3/4Domain Redirection.htacces code for redirecting yourwebsite.com to www.yourwebsite.comRewriteCond %{HTTP_HOST} ^yourwebsite.comRewriteRule (.*) http://www.yourwebsite.com/$1 [R=301,L]Sub Domain RedirectionSub domain redirection mapping to folder. Here http://www.yourwebsite.com is connectingto website_folder folder.RewriteCond %{HTTP_HOST} ^www.yourwebsite.com$RewriteCond %{REQUEST_URI} !^/website_folder/RewriteRule (.*) /website_folder/$1Here http://subdomain.yourwebsite.com is connecting to subdomain_folderfolder.RewriteCond %{HTTP_HOST} ^subdomain.yourwebsite.com$RewriteCond %{REQUEST_URI} !^/subdomain_folder/RewriteRule (.*) /subdomain_folder/$1Htaccess File Inside The Folder.Old Domain Redirectionhtaccess code for redirecting old domain(abc.com) to new domain(xyz.com). Livedemo fglogin.com is now redirecting to oauthlogin.comRewriteCond %{HTTP_HOST} ^abc.comRewriteRule (.*) http://www.xyz.com/$1 [R=301,L]RewriteCond %{HTTP_HOST} ^www.abc.comRewriteRule (.*) http://www.abc.com/$1 [R=301,L]Friendly URLsFriendly/Pretty URLs help in search engine rankings.Profile URLProfile parameter allows [a-zA-Z0-9_-] these inputs. More help read Understanding RegularExpressionhttp://labs.9lessons.info/profile.php?username=srinivastohttp://labs.9lessons.info/srinivasRewriteRule ^([a-zA-Z0-9_-]+)$ profile.php?username=$1
11/23/13 Htaccess File Tutorial and Tips.www.9lessons.info/2013/11/htaccess-file-tutorial-and-tips.html 4/4RewriteRule ^([a-zA-Z0-9_-]+)/$ profile.php?username=$1Messages URLhttp://labs.9lessons.info/messages.php?message_username=srinivastohttp://labs.9lessons.info/messages/srinivasRewriteRule ^messages/([a-zA-Z0-9_-]+)$ messages.php?message_username=$1RewriteRule ^messages/([a-zA-Z0-9_-]+)/$ messages.php?message_username=$1Friends URLhttp://labs.9lessons.info/friends.php?username=srinivastohttp://labs.9lessons.info/friends/srinivasRewriteRule ^friends/([a-zA-Z0-9_-]+)$ friends.php?username=$1RewriteRule ^friends/([a-zA-Z0-9_-]+)/$ friends.php?username=$1Friends URL with Two ParametersHere the first parameter allows [a-zA-Z0-9_-] and second parameter allows only number [0-9]http://labs.9lessons.info/friends.php?username=srinivas&page=2tohttp://labs.9lessons.info/friends/srinivas/2RewriteRule ^friends/([a-zA-Z0-9_-]+)/([0-9]+)$ friends.php?username=$1&page=$2RewriteRule ^friends/([a-zA-Z0-9_-]+)/([0-9]+)/$ friends.php?username=$1&page=$2Hiding File Extensionhttp://www.yourwebsite.com/index.htmltohttp://www.yourwebsite.com/indexRewriteRule ^([^/.]+)/?$ $1.html

Recommended

PDF
Technical SEO: .htaccess & 301 Redirects
PDF
PHP Includes
PPTX
WordPress Ann Arbor: Redirects and Robots for Accurate Analytics Results
PPTX
asp.net Webconfiguration
 
PPT
Drupal Installation & Configuration
ODP
Php File Upload
PPTX
crtical points for customizing Joomla templates
PDF
Deployment with ExpressionEngine
PDF
Apache Server Tutorial
PDF
Making Your Own URL Shortening Service
PPT
PDF
puissance-2roue
PPT
Apache
PPTX
Uploading a file with php
PPT
Local Drupal MultiSite Set-up
PPTX
Rhel6
PPT
Apache Web Server Setup 3
PPT
Apache Ppt
KEY
Switching search to SOLR
 
PPT
Apache Web Server Setup 1
PPT
File Upload
PPTX
CIT499 Semester Project
PDF
How to use_000webhost
 
PPT
How to Hack Website using SQL Injection Attack
PPTX
PHP Hypertext Preprocessor
PDF
Getting Under the Hood - WordPress File & Directory Structure
PPT
Apache Web Server Setup 4
PDF
Defeating Cross-Site Scripting with Content Security Policy
PDF
testing pdf doc

More Related Content

PDF
Technical SEO: .htaccess & 301 Redirects
PDF
PHP Includes
PPTX
WordPress Ann Arbor: Redirects and Robots for Accurate Analytics Results
PPTX
asp.net Webconfiguration
 
PPT
Drupal Installation & Configuration
ODP
Php File Upload
PPTX
crtical points for customizing Joomla templates
PDF
Deployment with ExpressionEngine
Technical SEO: .htaccess & 301 Redirects
PHP Includes
WordPress Ann Arbor: Redirects and Robots for Accurate Analytics Results
asp.net Webconfiguration
 
Drupal Installation & Configuration
Php File Upload
crtical points for customizing Joomla templates
Deployment with ExpressionEngine

What's hot

PDF
Apache Server Tutorial
PDF
Making Your Own URL Shortening Service
PPT
PDF
puissance-2roue
PPT
Apache
PPTX
Uploading a file with php
PPT
Local Drupal MultiSite Set-up
PPTX
Rhel6
PPT
Apache Web Server Setup 3
PPT
Apache Ppt
KEY
Switching search to SOLR
 
PPT
Apache Web Server Setup 1
PPT
File Upload
PPTX
CIT499 Semester Project
PDF
How to use_000webhost
 
PPT
How to Hack Website using SQL Injection Attack
PPTX
PHP Hypertext Preprocessor
PDF
Getting Under the Hood - WordPress File & Directory Structure
PPT
Apache Web Server Setup 4
PDF
Defeating Cross-Site Scripting with Content Security Policy
Apache Server Tutorial
Making Your Own URL Shortening Service
puissance-2roue
Apache
Uploading a file with php
Local Drupal MultiSite Set-up
Rhel6
Apache Web Server Setup 3
Apache Ppt
Switching search to SOLR
 
Apache Web Server Setup 1
File Upload
CIT499 Semester Project
How to use_000webhost
 
How to Hack Website using SQL Injection Attack
PHP Hypertext Preprocessor
Getting Under the Hood - WordPress File & Directory Structure
Apache Web Server Setup 4
Defeating Cross-Site Scripting with Content Security Policy

Similar to Htaccess file tutorial and tips

PDF
testing pdf doc
PDF
test pdf
PPT
Comparative Development Methodologies
PPTX
.htaccess
KEY
mod_rewrite bootcamp, Ohio LInux 2011
KEY
URL Mapping, with and without mod_rewrite
PPTX
Part 2 of Advanced SEO tips for Exponent CMS
KEY
mod_rewrite
PPT
Apache mod_rewrite
PDF
mod_rewrite
PPT
Google Bot Herding, PageRank Sculpting and Manipulation
PDF
mod_rewrite
ODP
Learn how to use the .htaccess file
PPTX
Htaccess crash course for Beginners
PDF
Apache Web Server Administration
PPT
Testing
DOC
12 Rocking Apache .htaccess Tutorial ...
PPT
Tour of sh404SEF - SEO and security for Joomla
testing pdf doc
test pdf
Comparative Development Methodologies
.htaccess
mod_rewrite bootcamp, Ohio LInux 2011
URL Mapping, with and without mod_rewrite
Part 2 of Advanced SEO tips for Exponent CMS
mod_rewrite
Apache mod_rewrite
mod_rewrite
Google Bot Herding, PageRank Sculpting and Manipulation
mod_rewrite
Learn how to use the .htaccess file
Htaccess crash course for Beginners
Apache Web Server Administration
Testing
12 Rocking Apache .htaccess Tutorial ...
Tour of sh404SEF - SEO and security for Joomla

Htaccess file tutorial and tips

  • 1.
    11/23/13 Htaccess FileTutorial and Tips.www.9lessons.info/2013/11/htaccess-file-tutorial-and-tips.html 1/4After posting Understanding of Regular Expression article most of my readers are expectingAfter posting Understanding of Regular Expression article most of my readers are expecting.htaccess basics, and I did not find any useful article on Google first page results. Specially I.htaccess basics, and I did not find any useful article on Google first page results. Specially Ilove to writelove to write.htaccess.htaccess file, using this you can easily configure and redirect Apache Web Serverfile, using this you can easily configure and redirect Apache Web Serverfile system. This post will explain you how to create friendly URLs, sub domain directory re-file system. This post will explain you how to create friendly URLs, sub domain directory re-directions and many more.directions and many more.Download Script Live DemoNote: .htaccess file will be in hidden format, please change your folder and file settings to view thisfile.How to Create a .htaccess File?Open any text editor application and file save as with .htaccess name andenablemod_rewrite extension in php.ini file in Apache Web Server configurations.Default directory Listing
  • 2.
    11/23/13 Htaccess FileTutorial and Tips.www.9lessons.info/2013/11/htaccess-file-tutorial-and-tips.html 2/4Disable directory ListingIf you want to disable folder files listing, include following code.# Disable Directory BrowsingOptions All -IndexesError PagesHere error page is redirecting to error.html.errorDocument 400 http://www.youwebsite.com/error.htmlerrorDocument 401 http://www.youwebsite.com/error.htmlerrorDocument 404 http://www.youwebsite.com/error.htmlerrorDocument 500 http://www.youwebsite.com/error.htmlRewriteEngine On it is turn on Rewrite Rules in Apache Server. if you want to turn off, just changethe value to off.RewriteEngine on
  • 3.
    11/23/13 Htaccess FileTutorial and Tips.www.9lessons.info/2013/11/htaccess-file-tutorial-and-tips.html 3/4Domain Redirection.htacces code for redirecting yourwebsite.com to www.yourwebsite.comRewriteCond %{HTTP_HOST} ^yourwebsite.comRewriteRule (.*) http://www.yourwebsite.com/$1 [R=301,L]Sub Domain RedirectionSub domain redirection mapping to folder. Here http://www.yourwebsite.com is connectingto website_folder folder.RewriteCond %{HTTP_HOST} ^www.yourwebsite.com$RewriteCond %{REQUEST_URI} !^/website_folder/RewriteRule (.*) /website_folder/$1Here http://subdomain.yourwebsite.com is connecting to subdomain_folderfolder.RewriteCond %{HTTP_HOST} ^subdomain.yourwebsite.com$RewriteCond %{REQUEST_URI} !^/subdomain_folder/RewriteRule (.*) /subdomain_folder/$1Htaccess File Inside The Folder.Old Domain Redirectionhtaccess code for redirecting old domain(abc.com) to new domain(xyz.com). Livedemo fglogin.com is now redirecting to oauthlogin.comRewriteCond %{HTTP_HOST} ^abc.comRewriteRule (.*) http://www.xyz.com/$1 [R=301,L]RewriteCond %{HTTP_HOST} ^www.abc.comRewriteRule (.*) http://www.abc.com/$1 [R=301,L]Friendly URLsFriendly/Pretty URLs help in search engine rankings.Profile URLProfile parameter allows [a-zA-Z0-9_-] these inputs. More help read Understanding RegularExpressionhttp://labs.9lessons.info/profile.php?username=srinivastohttp://labs.9lessons.info/srinivasRewriteRule ^([a-zA-Z0-9_-]+)$ profile.php?username=$1
  • 4.
    11/23/13 Htaccess FileTutorial and Tips.www.9lessons.info/2013/11/htaccess-file-tutorial-and-tips.html 4/4RewriteRule ^([a-zA-Z0-9_-]+)/$ profile.php?username=$1Messages URLhttp://labs.9lessons.info/messages.php?message_username=srinivastohttp://labs.9lessons.info/messages/srinivasRewriteRule ^messages/([a-zA-Z0-9_-]+)$ messages.php?message_username=$1RewriteRule ^messages/([a-zA-Z0-9_-]+)/$ messages.php?message_username=$1Friends URLhttp://labs.9lessons.info/friends.php?username=srinivastohttp://labs.9lessons.info/friends/srinivasRewriteRule ^friends/([a-zA-Z0-9_-]+)$ friends.php?username=$1RewriteRule ^friends/([a-zA-Z0-9_-]+)/$ friends.php?username=$1Friends URL with Two ParametersHere the first parameter allows [a-zA-Z0-9_-] and second parameter allows only number [0-9]http://labs.9lessons.info/friends.php?username=srinivas&page=2tohttp://labs.9lessons.info/friends/srinivas/2RewriteRule ^friends/([a-zA-Z0-9_-]+)/([0-9]+)$ friends.php?username=$1&page=$2RewriteRule ^friends/([a-zA-Z0-9_-]+)/([0-9]+)/$ friends.php?username=$1&page=$2Hiding File Extensionhttp://www.yourwebsite.com/index.htmltohttp://www.yourwebsite.com/indexRewriteRule ^([^/.]+)/?$ $1.html

[8]ページ先頭

©2009-2025 Movatter.jp