{"id":13341,"date":"2017-09-20T13:11:56","date_gmt":"2017-09-20T13:11:56","guid":{"rendered":"https:\/\/www.awardspace.com\/?page_id=13341"},"modified":"2024-02-27T13:58:58","modified_gmt":"2024-02-27T13:58:58","slug":"mod-rewrite","status":"publish","type":"post","link":"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/","title":{"rendered":"How to use mod_rewrite (RewriteRule\/RewriteCond)"},"content":{"rendered":"<p>In this tutorial, we are going to walk you through the process of enabling mod_rewrite on your AwardSpace web server.<\/p>\n<p>&nbsp;<\/p>\n<h2>What is Mod_Rewrite?<\/h2>\n<p><strong>Mod_rewrite<\/strong> is an Apache module that helps you perform redirects and define rewrite rules with the use of a <a href=\"https:\/\/httpd.apache.org\/docs\/2.4\/howto\/htaccess.html\">.htaccess<\/a> file.<\/p>\n<p>For more detailed information, please visit the official Apache Module mod_rewrite <a href=\"https:\/\/httpd.apache.org\/docs\/current\/mod\/mod_rewrite.html\">page<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<h2>How Can I Enable the Apache Rewrite Module on a Shared Hosting Account?<\/h2>\n<p>The Apache module mod_rewrite comes preinstalled with all shared hosting plans. Therefore, you will not be required to perform any manual installation of the module on the server.<\/p>\n<p>In order to enable the rewrite module on your website, make sure that your .htaccess contains the following two lines of code:<\/p>\n<div style=\"background-color: #333300;\"><code><span style=\"color: #d9d9d9;\">\u00a0\u00a0RewriteEngine On<\/span><br \/>\n<span style=\"color: #d9d9d9;\">\u00a0\u00a0RewriteBase \/<\/span><\/code><\/div>\n<p>&nbsp;<\/p>\n<p>At the end, your code should look similar to the following:<\/p>\n<div style=\"background-color: #333300;\"><code><span style=\"color: #d9d9d9;\">\u00a0\u00a0RewriteEngine On<\/span><br \/>\n<span style=\"color: #d9d9d9;\">\u00a0\u00a0RewriteBase \/<\/span><br \/>\n<span style=\"color: #d9d9d9;\">\u00a0\u00a0RewriteRule ^index\\.php$ - [L]<\/span><br \/>\n<span style=\"color: #d9d9d9;\">\u00a0\u00a0RewriteCond %{REQUEST_FILENAME} !-f<\/span><br \/>\n<span style=\"color: #d9d9d9;\">\u00a0\u00a0RewriteCond %{REQUEST_FILENAME} !-d<\/span><br \/>\n<span style=\"color: #d9d9d9;\">\u00a0\u00a0RewriteRule . \/index.php [L]<\/span><\/code><\/div>\n<p>&nbsp;<\/p>\n<p><strong>Note<\/strong>: If you have installed your application in a subdirectory of your domain name (domain.com\/site\/ for example), it will be necessary to make a couple of slight modifications to the code:<\/p>\n<div style=\"background-color: #333300;\"><code><span style=\"color: #d9d9d9;\">\u00a0\u00a0RewriteEngine On<\/span><br \/>\n<span style=\"color: #d9d9d9;\">\u00a0\u00a0RewriteBase \/site\/<\/span><br \/>\n<span style=\"color: #d9d9d9;\">\u00a0\u00a0RewriteRule ^index\\.php$ - [L]<\/span><br \/>\n<span style=\"color: #d9d9d9;\">\u00a0\u00a0RewriteCond %{REQUEST_FILENAME} !-f<\/span><br \/>\n<span style=\"color: #d9d9d9;\">\u00a0\u00a0RewriteCond %{REQUEST_FILENAME} !-d<\/span><br \/>\n<span style=\"color: #d9d9d9;\">\u00a0\u00a0RewriteRule . \/site\/index.php [L]<\/span><\/code><\/div>\n<p>&nbsp;<\/p>\n<p>Please make sure that you replace <strong><code>site<\/code><\/strong> with your actual directory name.<\/p>\n<p>&nbsp;<\/p>\n<h2>How Can I Enable the Rewrite Module on a VPS Server?<\/h2>\n<p>On a Debian\/Ubuntu server, the Apache rewrite module is installed, but not enabled by default.<\/p>\n<p>If you have an active VPS account and wish to enable mod_rewrite on your web server, you should perform the following steps:<\/p>\n<p>&nbsp;<\/p>\n<p>1. Log into your VPS account via SSH and execute the following command in Terminal:<\/p>\n<div style=\"background-color: #333300;\"><code><span style=\"color: #d9d9d9;\">\u00a0\u00a0a2enmod rewrite<\/span><\/code><\/div>\n<p>&nbsp;<\/p>\n<p>2. Restart the Apache web server:<\/p>\n<div style=\"background-color: #333300;\"><code><span style=\"color: #d9d9d9;\">\u00a0\u00a0\/etc\/init.d\/apache2 restart<\/span><\/code><\/div>\n<p>&nbsp;<\/p>\n<p>3. Locate the main .htaccess file in your web application&#8217;s root directory, and then copy and paste the below code into it:<\/p>\n<div style=\"background-color: #333300;\"><code><span style=\"color: #d9d9d9;\">\u00a0\u00a0RewriteEngine On<\/span><br \/>\n<span style=\"color: #d9d9d9;\">\u00a0\u00a0RewriteBase \/<\/span><br \/>\n<span style=\"color: #d9d9d9;\">\u00a0\u00a0RewriteRule ^index\\.php$ - [L]<\/span><br \/>\n<span style=\"color: #d9d9d9;\">\u00a0\u00a0RewriteCond %{REQUEST_FILENAME} !-f<\/span><br \/>\n<span style=\"color: #d9d9d9;\">\u00a0\u00a0RewriteCond %{REQUEST_FILENAME} !-d<\/span><br \/>\n<span style=\"color: #d9d9d9;\">\u00a0\u00a0RewriteRule . \/index.php [L]<\/span><\/code><\/div>\n<p>&nbsp;<\/p>\n<p>Save the changes you have just made and re-test your application.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we are going to walk you through the process of enabling mod_rewrite on your AwardSpace web server. &nbsp; What is Mod_Rewrite? Mod_rewrite is an Apache module that helps you perform redirects and define rewrite rules with the use of a .htaccess file. For more detailed information, please visit the official Apache Module [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":33819,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"off","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[78],"tags":[],"class_list":["post-13341","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-htaccess"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Enable Mod_Rewrite on a Web Server? | AwardSpace.com<\/title>\n<meta name=\"description\" content=\"In this tutorial, we are going to walk you through the process of enabling the Apache module mod_rewrite on your AwardSpace web server.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Enable Mod_Rewrite on a Web Server? | AwardSpace.com\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, we are going to walk you through the process of enabling the Apache module mod_rewrite on your AwardSpace web server.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/\" \/>\n<meta property=\"og:site_name\" content=\"AwardSpace.com\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/AwardSpace\/\" \/>\n<meta property=\"article:published_time\" content=\"2017-09-20T13:11:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-02-27T13:58:58+00:00\" \/>\n<meta name=\"author\" content=\"ivailod\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@awspace\" \/>\n<meta name=\"twitter:site\" content=\"@awspace\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"ivailod\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/\"},\"author\":{\"name\":\"ivailod\",\"@id\":\"https:\/\/www.awardspace.com\/#\/schema\/person\/ce135bfb9f8b0d51d047abe11d77b221\"},\"headline\":\"How to use mod_rewrite (RewriteRule\/RewriteCond)\",\"datePublished\":\"2017-09-20T13:11:56+00:00\",\"dateModified\":\"2024-02-27T13:58:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/\"},\"wordCount\":297,\"publisher\":{\"@id\":\"https:\/\/www.awardspace.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/#primaryimage\"},\"thumbnailUrl\":\"\",\"articleSection\":[\".htaccess\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/\",\"url\":\"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/\",\"name\":\"How to Enable Mod_Rewrite on a Web Server? | AwardSpace.com\",\"isPartOf\":{\"@id\":\"https:\/\/www.awardspace.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/#primaryimage\"},\"thumbnailUrl\":\"\",\"datePublished\":\"2017-09-20T13:11:56+00:00\",\"dateModified\":\"2024-02-27T13:58:58+00:00\",\"description\":\"In this tutorial, we are going to walk you through the process of enabling the Apache module mod_rewrite on your AwardSpace web server.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/#primaryimage\",\"url\":\"\",\"contentUrl\":\"\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.awardspace.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Knowledge Base\",\"item\":\"https:\/\/www.awardspace.com\/kb\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Website Management \u2013 Advanced\",\"item\":\"https:\/\/www.awardspace.com\/kb\/website-management-advanced\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\".htaccess\",\"item\":\"https:\/\/www.awardspace.com\/kb\/website-management-advanced\/htaccess\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"How to use mod_rewrite (RewriteRule\/RewriteCond)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.awardspace.com\/#website\",\"url\":\"https:\/\/www.awardspace.com\/\",\"name\":\"AwardSpace.com\",\"description\":\"Free Web Hosting with PHP, MySQL, Email Sending, No Ads\",\"publisher\":{\"@id\":\"https:\/\/www.awardspace.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.awardspace.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.awardspace.com\/#organization\",\"name\":\"AwardSpace.com\",\"url\":\"https:\/\/www.awardspace.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.awardspace.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.awardspace.com\/wp-content\/uploads\/2018\/08\/awardspace_logo.png\",\"contentUrl\":\"https:\/\/www.awardspace.com\/wp-content\/uploads\/2018\/08\/awardspace_logo.png\",\"width\":1759,\"height\":176,\"caption\":\"AwardSpace.com\"},\"image\":{\"@id\":\"https:\/\/www.awardspace.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/AwardSpace\/\",\"https:\/\/x.com\/awspace\",\"https:\/\/www.instagram.com\/awardspace\/\",\"https:\/\/www.quora.com\/profile\/Award-Space\",\"https:\/\/www.linkedin.com\/company\/19214384\/\",\"https:\/\/www.reddit.com\/user\/AwardSpace\",\"https:\/\/www.pinterest.com\/awardspace\/\",\"https:\/\/www.youtube.com\/user\/AwardspaceWebHosting\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.awardspace.com\/#\/schema\/person\/ce135bfb9f8b0d51d047abe11d77b221\",\"name\":\"ivailod\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.awardspace.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g\",\"caption\":\"ivailod\"},\"url\":\"https:\/\/www.awardspace.com\/author\/ivailod\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Enable Mod_Rewrite on a Web Server? | AwardSpace.com","description":"In this tutorial, we are going to walk you through the process of enabling the Apache module mod_rewrite on your AwardSpace web server.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/","og_locale":"en_US","og_type":"article","og_title":"How to Enable Mod_Rewrite on a Web Server? | AwardSpace.com","og_description":"In this tutorial, we are going to walk you through the process of enabling the Apache module mod_rewrite on your AwardSpace web server.","og_url":"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/","og_site_name":"AwardSpace.com","article_publisher":"https:\/\/www.facebook.com\/AwardSpace\/","article_published_time":"2017-09-20T13:11:56+00:00","article_modified_time":"2024-02-27T13:58:58+00:00","author":"ivailod","twitter_card":"summary_large_image","twitter_creator":"@awspace","twitter_site":"@awspace","twitter_misc":{"Written by":"ivailod","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/#article","isPartOf":{"@id":"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/"},"author":{"name":"ivailod","@id":"https:\/\/www.awardspace.com\/#\/schema\/person\/ce135bfb9f8b0d51d047abe11d77b221"},"headline":"How to use mod_rewrite (RewriteRule\/RewriteCond)","datePublished":"2017-09-20T13:11:56+00:00","dateModified":"2024-02-27T13:58:58+00:00","mainEntityOfPage":{"@id":"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/"},"wordCount":297,"publisher":{"@id":"https:\/\/www.awardspace.com\/#organization"},"image":{"@id":"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/#primaryimage"},"thumbnailUrl":"","articleSection":[".htaccess"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/","url":"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/","name":"How to Enable Mod_Rewrite on a Web Server? | AwardSpace.com","isPartOf":{"@id":"https:\/\/www.awardspace.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/#primaryimage"},"image":{"@id":"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/#primaryimage"},"thumbnailUrl":"","datePublished":"2017-09-20T13:11:56+00:00","dateModified":"2024-02-27T13:58:58+00:00","description":"In this tutorial, we are going to walk you through the process of enabling the Apache module mod_rewrite on your AwardSpace web server.","breadcrumb":{"@id":"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.awardspace.com\/kb\/mod-rewrite\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/#primaryimage","url":"","contentUrl":""},{"@type":"BreadcrumbList","@id":"https:\/\/www.awardspace.com\/kb\/mod-rewrite\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.awardspace.com\/"},{"@type":"ListItem","position":2,"name":"Knowledge Base","item":"https:\/\/www.awardspace.com\/kb\/"},{"@type":"ListItem","position":3,"name":"Website Management \u2013 Advanced","item":"https:\/\/www.awardspace.com\/kb\/website-management-advanced\/"},{"@type":"ListItem","position":4,"name":".htaccess","item":"https:\/\/www.awardspace.com\/kb\/website-management-advanced\/htaccess\/"},{"@type":"ListItem","position":5,"name":"How to use mod_rewrite (RewriteRule\/RewriteCond)"}]},{"@type":"WebSite","@id":"https:\/\/www.awardspace.com\/#website","url":"https:\/\/www.awardspace.com\/","name":"AwardSpace.com","description":"Free Web Hosting with PHP, MySQL, Email Sending, No Ads","publisher":{"@id":"https:\/\/www.awardspace.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.awardspace.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.awardspace.com\/#organization","name":"AwardSpace.com","url":"https:\/\/www.awardspace.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.awardspace.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.awardspace.com\/wp-content\/uploads\/2018\/08\/awardspace_logo.png","contentUrl":"https:\/\/www.awardspace.com\/wp-content\/uploads\/2018\/08\/awardspace_logo.png","width":1759,"height":176,"caption":"AwardSpace.com"},"image":{"@id":"https:\/\/www.awardspace.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/AwardSpace\/","https:\/\/x.com\/awspace","https:\/\/www.instagram.com\/awardspace\/","https:\/\/www.quora.com\/profile\/Award-Space","https:\/\/www.linkedin.com\/company\/19214384\/","https:\/\/www.reddit.com\/user\/AwardSpace","https:\/\/www.pinterest.com\/awardspace\/","https:\/\/www.youtube.com\/user\/AwardspaceWebHosting"]},{"@type":"Person","@id":"https:\/\/www.awardspace.com\/#\/schema\/person\/ce135bfb9f8b0d51d047abe11d77b221","name":"ivailod","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.awardspace.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g","caption":"ivailod"},"url":"https:\/\/www.awardspace.com\/author\/ivailod\/"}]}},"_links":{"self":[{"href":"https:\/\/www.awardspace.com\/wp-json\/wp\/v2\/posts\/13341","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.awardspace.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.awardspace.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.awardspace.com\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.awardspace.com\/wp-json\/wp\/v2\/comments?post=13341"}],"version-history":[{"count":0,"href":"https:\/\/www.awardspace.com\/wp-json\/wp\/v2\/posts\/13341\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.awardspace.com\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/www.awardspace.com\/wp-json\/wp\/v2\/media?parent=13341"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.awardspace.com\/wp-json\/wp\/v2\/categories?post=13341"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.awardspace.com\/wp-json\/wp\/v2\/tags?post=13341"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}