{"id":36343,"date":"2021-05-05T12:30:00","date_gmt":"2021-05-05T17:30:00","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=36343"},"modified":"2022-06-03T03:31:40","modified_gmt":"2022-06-03T08:31:40","slug":"how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\/","title":{"rendered":"How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 20.04"},"content":{"rendered":"<div id=\"bsf_rt_marker\"><\/div>\r\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"742\" height=\"372\" class=\"wp-image-36949\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2021\/04\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20.04.jpg\" alt=\"\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2021\/04\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20.04.jpg 742w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2021\/04\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20.04-300x150.jpg 300w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2021\/04\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20.04-150x75.jpg 150w\" sizes=\"(max-width: 742px) 100vw, 742px\" \/><\/figure>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"alignright size-large is-resized\"><img decoding=\"async\" class=\"wp-image-36951\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2021\/03\/rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20.04.png\" alt=\"rewrite urls with mod_rewrite for apache on ubuntu 20.04\" width=\"100\" height=\"100\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2021\/03\/rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20.04.png 200w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2021\/03\/rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20.04-150x150.png 150w\" sizes=\"(max-width: 100px) 100vw, 100px\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<p>The mod_rewrite is an Apache module that uses a rule-based rewriting engine. It is used for translating and <a href=\"https:\/\/www.rosehosting.com\/blog\/how-to-redirect-a-domain\/\">redirecting the requested URL to a new URL<\/a>. It allows a URL to be changed dynamically. So the visitor never sees the URL change in the address bar. With mod_rewrite, you can rewrite an unlimited number of rules. This will allow you to rewrite the URL based on environment variables, HTTP headers, and server variables.<\/p>\r\n\r\n\r\n\r\n<p><!--more--><\/p>\r\n\r\n\r\n\r\n<p>In this post, we will show how to use mod_rewrite to rewrite the URL for Apache on <a href=\"https:\/\/www.rosehosting.com\/ubuntu-hosting\/\">Ubuntu VPS<\/a>.<\/p>\r\n\r\n\r\n\r\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69ea46dea7568\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"ez-toc-cssicon\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69ea46dea7568\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\/#Prerequisites\" >Prerequisites<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\/#Step-1-Log-in-to-the-Server-Update-the-Server-OS-Packages\" >Step 1: Log in to the Server &amp; Update the Server OS Packages<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\/#Step-2-Install-Apache-Web-Server\" >Step 2: Install Apache Web Server<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\/#Step-3-Enable-mod-rewrite\" >Step 3: Enable mod_rewrite<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\/#Step-4-Enable-htaccess-Files\" >Step 4: Enable .htaccess Files<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\/#Step-5-Configure-URL-Rewrites\" >Step 5: Configure URL Rewrites<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-prerequisites\"><span class=\"ez-toc-section\" id=\"Prerequisites\"><\/span>Prerequisites<span class=\"ez-toc-section-end\"><\/span><\/h2>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li>Ubuntu 20.04 VPS (we\u2019ll be using our <a href=\"https:\/\/www.rosehosting.com\/managed-vps-hosting\/\">NVMe 2 VPS plan<\/a>)<\/li>\r\n<li>Access to the root user account (or access to an admin account with root privileges)<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id=\"h-step-1-log-in-to-the-server-update-the-server-os-packages\"><span class=\"ez-toc-section\" id=\"Step-1-Log-in-to-the-Server-Update-the-Server-OS-Packages\"><\/span>Step 1: Log in to the Server &amp; Update the Server OS Packages<span class=\"ez-toc-section-end\"><\/span><\/h2>\r\n\r\n\r\n\r\n<p>First, log in to your Ubuntu 20.04 server via SSH as the root user:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-preformatted\">ssh root@IP_Address -p Port_number<\/pre>\r\n\r\n\r\n\r\n<p>You must replace &#8216;IP_Address&#8217; and &#8216;Port_number&#8217; with your server&#8217;s respective IP address and <a href=\"https:\/\/www.rosehosting.com\/blog\/how-and-why-to-change-the-default-ssh-port-on-linux\/\">SSH port<\/a> number. Also, you should replace &#8216;root&#8217; with the username of the admin account if needed.<\/p>\r\n\r\n\r\n\r\n<p>Before we begin the installation, we should make sure that all the Ubuntu OS packages installed on the server are updated. You can do this by running the following commands:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-preformatted\">apt-get update -y\r\napt-get upgrade -y<\/pre>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id=\"h-step-2-install-apache-web-server\"><span class=\"ez-toc-section\" id=\"Step-2-Install-Apache-Web-Server\"><\/span>Step 2: Install Apache Web Server<span class=\"ez-toc-section-end\"><\/span><\/h2>\r\n\r\n\r\n\r\n<p>Before you start, make sure that Apache webserver package is installed in your system. If not installed, you can install it with the following command:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-preformatted\">apt-get install apache2 -y<\/pre>\r\n\r\n\r\n\r\n<p>Once the package is installed, start the Apache service with the following command:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-preformatted\">systemctl start apache2<\/pre>\r\n\r\n\r\n\r\n<p>Next, open your web browser and type the URL<strong> http:\/\/your-server-ip<\/strong> to verify the Apache webserver. If everything is fine, you should see the Apache test page:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"581\" class=\"wp-image-36952\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2021\/03\/mod_rewrite-for-apache-on-ubuntu-20.04.png\" alt=\"mod_rewrite for apache on ubuntu 20.04\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2021\/03\/mod_rewrite-for-apache-on-ubuntu-20.04.png 1024w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2021\/03\/mod_rewrite-for-apache-on-ubuntu-20.04-300x170.png 300w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2021\/03\/mod_rewrite-for-apache-on-ubuntu-20.04-150x85.png 150w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2021\/03\/mod_rewrite-for-apache-on-ubuntu-20.04-768x436.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id=\"h-step-3-enable-mod_rewrite\"><span class=\"ez-toc-section\" id=\"Step-3-Enable-mod-rewrite\"><\/span>Step 3: Enable mod_rewrite<span class=\"ez-toc-section-end\"><\/span><\/h2>\r\n\r\n\r\n\r\n<p>By default, the mod_rewrite module is installed with the Apache package but it is disabled. So you will need to enable it first.<\/p>\r\n\r\n\r\n\r\n<p>You can enable it with the following command:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-preformatted\">a2enmod rewrite<\/pre>\r\n\r\n\r\n\r\n<p>Next, restart the Apache service to apply the changes.<\/p>\r\n\r\n\r\n\r\n<p>Next, verify the Apache mod_rewrite module with the following command:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-preformatted\">apache2ctl -M | grep rewrite_module<\/pre>\r\n\r\n\r\n\r\n<p>You should get the following output:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-preformatted\"> rewrite_module (shared)\r\n<\/pre>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id=\"h-step-4-enable-htaccess-files\"><span class=\"ez-toc-section\" id=\"Step-4-Enable-htaccess-Files\"><\/span>Step 4: Enable .htaccess Files<span class=\"ez-toc-section-end\"><\/span><\/h2>\r\n\r\n\r\n\r\n<p>You can set up rewrite rules directly in the Apache main configuration file. However, it is recommended to write rules in the .htaccess file inside each website.<\/p>\r\n\r\n\r\n\r\n<p>By default, Apache does not allow to use .htaccess file. So you will need to enable the .htaccess file in your default virtual host configuration file.<\/p>\r\n\r\n\r\n\r\n<p>To do so, edit the Apache default virtual host configuration file:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-preformatted\">nano \/etc\/apache2\/sites-available\/000-default.conf<\/pre>\r\n\r\n\r\n\r\n<p>Add the following lines before the line :<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-preformatted\">&lt;Directory \/var\/www\/html&gt;\r\n        Options Indexes FollowSymLinks MultiViews\r\n        AllowOverride All\r\n        Require all granted\r\n&lt;\/Directory&gt;\r\n<\/pre>\r\n\r\n\r\n\r\n<p>Make sure to Save and close the file then restart the Apache service to apply the changes:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-preformatted\">systemctl restart apache2<\/pre>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id=\"h-step-5-configure-url-rewrites\"><span class=\"ez-toc-section\" id=\"Step-5-Configure-URL-Rewrites\"><\/span>Step 5: Configure URL Rewrites<span class=\"ez-toc-section-end\"><\/span><\/h2>\r\n\r\n\r\n\r\n<p>To understand how URL rewrites work, we will create a home.html page in the Apache document root directory. We will then setup a basic <a href=\"https:\/\/www.rosehosting.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\/\">URL rewrite<\/a> that will allows to access the page http:\/\/your-server-ip\/home and convert it to the actual page path http:\/\/your-server-ip\/home.html.<\/p>\r\n\r\n\r\n\r\n<p>First, let&#8217;s create a home.html page:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-preformatted\">nano \/var\/www\/html\/home.html<\/pre>\r\n\r\n\r\n\r\n<p>Add the following contents:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-preformatted\">&lt;html&gt;\r\n    &lt;head&gt;\r\n        &lt;title&gt;Home&lt;\/title&gt;\r\n    &lt;\/head&gt;\r\n    &lt;body&gt;\r\n        &lt;h1&gt;Home Page&lt;\/h1&gt;\r\n\r\n&lt;h2&gt;This is my home page&lt;\/h2&gt;\r\n    &lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\r\n\r\n\r\n\r\n<p>Save and close the file when you are finished.<\/p>\r\n\r\n\r\n\r\n<p>Next, create a .htaccess file inside the default document root directory of the website to test mod_rewrite.<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-preformatted\">nano \/var\/www\/html\/.htaccess<\/pre>\r\n\r\n\r\n\r\n<p>First, add the following line to enable the rewrite engine:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-preformatted\">RewriteEngine on\r\n<\/pre>\r\n\r\n\r\n\r\n<p>Next, add the following rewrite rule that redirects visitors to home.html if they request the page http:\/\/your-server-ip\/home.<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-preformatted\">RewriteRule ^home$ home.html [NC]\r\n<\/pre>\r\n\r\n\r\n\r\n<p>Save and close the file when you are finished.<\/p>\r\n\r\n\r\n\r\n<p>A brief explanation of rewrite rule syntax is shown below:<\/p>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li><strong>^ <\/strong>This will match any text after the server IP address.<\/li>\r\n<li><strong>$<\/strong> This will indicates the end of the URL.<\/li>\r\n<li><strong>home<\/strong> This will match the actual string home<\/li>\r\n<li><strong>home.html<\/strong> This will define the actual file that the visitor accesses.<\/li>\r\n<li><strong>[NC]<\/strong> This will makes the rule case insensitive.<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<p>You can now visit the home page at <strong>http:\/\/your-server-ip\/home<\/strong> on your web browser. Apache will redirect to the page home.html as shown below:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"989\" height=\"466\" class=\"wp-image-36349\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2021\/03\/instructional-guide-on-how-to-rewrite-urlss-with-mod_rewrite-for-apache-on-ubuntu-20.04.png\" alt=\"instructional guide on how to rewrite urlss with mod_rewrite for apache on ubuntu 20.04\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2021\/03\/instructional-guide-on-how-to-rewrite-urlss-with-mod_rewrite-for-apache-on-ubuntu-20.04.png 989w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2021\/03\/instructional-guide-on-how-to-rewrite-urlss-with-mod_rewrite-for-apache-on-ubuntu-20.04-300x141.png 300w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2021\/03\/instructional-guide-on-how-to-rewrite-urlss-with-mod_rewrite-for-apache-on-ubuntu-20.04-150x71.png 150w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2021\/03\/instructional-guide-on-how-to-rewrite-urlss-with-mod_rewrite-for-apache-on-ubuntu-20.04-768x362.png 768w\" sizes=\"(max-width: 989px) 100vw, 989px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n\r\n\r\n<p>Of course, you don&#8217;t have to do any of this if you use one of our <a href=\"https:\/\/www.rosehosting.com\/blog\/what-is-linux-vps-hosting\/\">Linux VPS Hosting<\/a> services, in which case you can simply ask our expert Linux admins to set up this for you. They are available 24\u00d77 and will take care of your request immediately.<\/p>\r\n\r\n\r\n\r\n<p>PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.<\/p>\r\n","protected":false},"excerpt":{"rendered":"<p>The mod_rewrite is an Apache module that uses a rule-based rewriting engine. It is used for translating and redirecting the &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 20.04\" class=\"read-more button\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\/#more-36343\" aria-label=\"Read more about How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 20.04\">Read More<\/a><\/p>\n","protected":false},"author":4,"featured_media":36949,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1236,4,21,1698],"tags":[37,19,1152,59,1839],"class_list":["post-36343","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-guides","category-rosehosting","category-tips-and-tricks","category-ubuntu","tag-apache","tag-linux-vps-hosting","tag-rosehosting","tag-ubuntu","tag-ubuntu-20-04","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-33"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.4 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 20.04<\/title>\n<meta name=\"description\" content=\"Looking for a tutorial on How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 20.04? Click here for our complete guide.\" \/>\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.rosehosting.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 20.04\" \/>\n<meta property=\"og:description\" content=\"Looking for a tutorial on How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 20.04? Click here for our complete guide.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.rosehosting.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\/\" \/>\n<meta property=\"og:site_name\" content=\"RoseHosting\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/RoseHosting\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/rosehosting.helpdesk\" \/>\n<meta property=\"article:published_time\" content=\"2021-05-05T17:30:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-06-03T08:31:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2021\/04\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20.04.jpg?v=1619513880\" \/>\n\t<meta property=\"og:image:width\" content=\"742\" \/>\n\t<meta property=\"og:image:height\" content=\"372\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Jeff Wilson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 20.04\" \/>\n<meta name=\"twitter:description\" content=\"Looking for a tutorial on How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 20.04? Click here for our complete guide.\" \/>\n<meta name=\"twitter:creator\" content=\"@rosehosting\" \/>\n<meta name=\"twitter:site\" content=\"@rosehosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeff Wilson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\\\/\"},\"author\":{\"name\":\"Jeff Wilson\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/person\\\/7ce77a842fa6a9a7f8efa186f2353713\"},\"headline\":\"How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 20.04\",\"datePublished\":\"2021-05-05T17:30:00+00:00\",\"dateModified\":\"2022-06-03T08:31:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\\\/\"},\"wordCount\":737,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20.04.jpg\",\"keywords\":[\"apache\",\"linux vps hosting\",\"rosehosting\",\"ubuntu\",\"Ubuntu 20.04\"],\"articleSection\":[\"Guides\",\"RoseHosting Platform\",\"Tips and Tricks\",\"Ubuntu\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\\\/\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\\\/\",\"name\":\"How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 20.04\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20.04.jpg\",\"datePublished\":\"2021-05-05T17:30:00+00:00\",\"dateModified\":\"2022-06-03T08:31:40+00:00\",\"description\":\"Looking for a tutorial on How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 20.04? Click here for our complete guide.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20.04.jpg\",\"contentUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20.04.jpg\",\"width\":742,\"height\":372,\"caption\":\"RoseHosting.com Hosting Solutions SSL \\\/ Domains Support About Us Affiliates Blog Login How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 20.04\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 20.04\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/\",\"name\":\"RoseHosting.com\",\"description\":\"Premium Linux Tutorials Since 2001\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#organization\",\"name\":\"RoseHosting\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/android-chrome-192x192-1.png\",\"contentUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/android-chrome-192x192-1.png\",\"width\":192,\"height\":192,\"caption\":\"RoseHosting\"},\"image\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/RoseHosting\",\"https:\\\/\\\/x.com\\\/rosehosting\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/rosehosting\\\/\"],\"description\":\"RoseHosting is a leading Linux hosting provider, serving thousands of clients world-wide since 2001.\",\"email\":\"info@rosehosting.com\",\"telephone\":\"(314) 275-0414\",\"legalName\":\"Rose Web Services LLC\",\"foundingDate\":\"2001-04-02\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"11\",\"maxValue\":\"50\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/person\\\/7ce77a842fa6a9a7f8efa186f2353713\",\"name\":\"Jeff Wilson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g\",\"caption\":\"Jeff Wilson\"},\"description\":\"An experienced Linux veteran with many years of experience. Helping other Linux admins with frequent Linux and business-related blog posts on the RoseHosting blog. Techie by choice. Loving nature and travel. Happily married and father of two lovely children.\",\"sameAs\":[\"https:\\\/\\\/www.rosehosting.com\",\"https:\\\/\\\/www.facebook.com\\\/rosehosting.helpdesk\"],\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/author\\\/jwilson\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 20.04","description":"Looking for a tutorial on How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 20.04? Click here for our complete guide.","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.rosehosting.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\/","og_locale":"en_US","og_type":"article","og_title":"How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 20.04","og_description":"Looking for a tutorial on How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 20.04? Click here for our complete guide.","og_url":"https:\/\/www.rosehosting.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\/","og_site_name":"RoseHosting","article_publisher":"https:\/\/www.facebook.com\/RoseHosting","article_author":"https:\/\/www.facebook.com\/rosehosting.helpdesk","article_published_time":"2021-05-05T17:30:00+00:00","article_modified_time":"2022-06-03T08:31:40+00:00","og_image":[{"width":742,"height":372,"url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2021\/04\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20.04.jpg?v=1619513880","type":"image\/jpeg"}],"author":"Jeff Wilson","twitter_card":"summary_large_image","twitter_title":"How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 20.04","twitter_description":"Looking for a tutorial on How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 20.04? Click here for our complete guide.","twitter_creator":"@rosehosting","twitter_site":"@rosehosting","twitter_misc":{"Written by":"Jeff Wilson","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.rosehosting.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\/#article","isPartOf":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\/"},"author":{"name":"Jeff Wilson","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713"},"headline":"How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 20.04","datePublished":"2021-05-05T17:30:00+00:00","dateModified":"2022-06-03T08:31:40+00:00","mainEntityOfPage":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\/"},"wordCount":737,"commentCount":2,"publisher":{"@id":"https:\/\/www.rosehosting.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\/#primaryimage"},"thumbnailUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2021\/04\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20.04.jpg","keywords":["apache","linux vps hosting","rosehosting","ubuntu","Ubuntu 20.04"],"articleSection":["Guides","RoseHosting Platform","Tips and Tricks","Ubuntu"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.rosehosting.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.rosehosting.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\/","url":"https:\/\/www.rosehosting.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\/","name":"How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 20.04","isPartOf":{"@id":"https:\/\/www.rosehosting.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\/#primaryimage"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\/#primaryimage"},"thumbnailUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2021\/04\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20.04.jpg","datePublished":"2021-05-05T17:30:00+00:00","dateModified":"2022-06-03T08:31:40+00:00","description":"Looking for a tutorial on How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 20.04? Click here for our complete guide.","breadcrumb":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.rosehosting.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.rosehosting.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\/#primaryimage","url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2021\/04\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20.04.jpg","contentUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2021\/04\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20.04.jpg","width":742,"height":372,"caption":"RoseHosting.com Hosting Solutions SSL \/ Domains Support About Us Affiliates Blog Login How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 20.04"},{"@type":"BreadcrumbList","@id":"https:\/\/www.rosehosting.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.rosehosting.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 20.04"}]},{"@type":"WebSite","@id":"https:\/\/www.rosehosting.com\/blog\/#website","url":"https:\/\/www.rosehosting.com\/blog\/","name":"RoseHosting.com","description":"Premium Linux Tutorials Since 2001","publisher":{"@id":"https:\/\/www.rosehosting.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.rosehosting.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.rosehosting.com\/blog\/#organization","name":"RoseHosting","url":"https:\/\/www.rosehosting.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png","contentUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png","width":192,"height":192,"caption":"RoseHosting"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/RoseHosting","https:\/\/x.com\/rosehosting","https:\/\/www.linkedin.com\/in\/rosehosting\/"],"description":"RoseHosting is a leading Linux hosting provider, serving thousands of clients world-wide since 2001.","email":"info@rosehosting.com","telephone":"(314) 275-0414","legalName":"Rose Web Services LLC","foundingDate":"2001-04-02","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"11","maxValue":"50"}},{"@type":"Person","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713","name":"Jeff Wilson","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g","caption":"Jeff Wilson"},"description":"An experienced Linux veteran with many years of experience. Helping other Linux admins with frequent Linux and business-related blog posts on the RoseHosting blog. Techie by choice. Loving nature and travel. Happily married and father of two lovely children.","sameAs":["https:\/\/www.rosehosting.com","https:\/\/www.facebook.com\/rosehosting.helpdesk"],"url":"https:\/\/www.rosehosting.com\/blog\/author\/jwilson\/"}]}},"_links":{"self":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/36343","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/comments?post=36343"}],"version-history":[{"count":9,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/36343\/revisions"}],"predecessor-version":[{"id":41002,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/36343\/revisions\/41002"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/media\/36949"}],"wp:attachment":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/media?parent=36343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/categories?post=36343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/tags?post=36343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}