{"id":1863,"date":"2023-08-30T12:30:00","date_gmt":"2023-08-30T17:30:00","guid":{"rendered":"https:\/\/www.linuxcloudvps.com\/blog\/?p=1863"},"modified":"2023-08-29T12:08:20","modified_gmt":"2023-08-29T17:08:20","slug":"how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04","status":"publish","type":"post","link":"https:\/\/www.linuxcloudvps.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\/","title":{"rendered":"How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 22.04"},"content":{"rendered":"\n<p>The mod_rewrite is a module in Apache that utilizes a rule-based rewriting engine. It is employed for converting and redirecting the requested URL to a different URL. <\/p>\n\n\n\n<!--more-->\n\n\n\n<p>It enables the modification of a URL in real time. Consequently, the visitor will not observe any alterations to the URL in the address bar. By utilizing mod_rewrite, you can rewrite a limitless number of rules. <\/p>\n\n\n\n<p>This will permit you to modify the URL according to environmental variables, HTTP headers, and server variables.<\/p>\n\n\n\n<p>In this article, we will demonstrate the utilization of mod_rewrite to modify the URL for <a href=\"https:\/\/www.rosehosting.com\/apache-hosting\/\" title=\"\">Apache<\/a> on an Ubuntu machine.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ubuntu 22.04 with apache2 installed<\/li>\n\n\n\n<li>SSH root access or a regular system user with sudo privileges<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1. Login to the server<\/h2>\n\n\n\n<p>First, log in to your Ubuntu 22.04 server through SSH as the root user:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ssh root@IP_Address -p Port_number<\/pre>\n\n\n\n<p>You must replace \u2018IP_Address\u2018 and \u2018Port_number\u2018 with your server\u2019s respective IP address and SSH port number. Additionally, replace \u2018root\u2019 with the username of the system user with sudo privileges.<\/p>\n\n\n\n<p>You can check whether you have the proper Ubuntu version installed on your server with the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># lsb_release -a<\/pre>\n\n\n\n<p>You should get this output:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">No LSB modules are available.&lt;br&gt;Distributor ID: Ubuntu&lt;br&gt;Description: Ubuntu 22.04.2 LTS&lt;br&gt;Release: 22.04&lt;br&gt;Codename: jammy<\/pre>\n\n\n\n<p>Before starting, you have to make sure that all Ubuntu OS packages installed on the server are up to date. You can do this by running the following commands:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># apt update -y<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2. Enable mod_rewrite<\/h2>\n\n\n\n<p>By default, the mod_rewrite module comes pre-installed with the Apache package but is deactivated. Therefore, you will need to activate it first.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># a2enmod rewrite<\/pre>\n\n\n\n<p>After running the command, you will be asked to restart Apache.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># systemctl restart apache2<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3. Enable .htaccess<\/h2>\n\n\n\n<p>You can configure rewrite rules directly in the primary Apache configuration file. However, creating rules in the .htaccess file within each website is advisable.<\/p>\n\n\n\n<p>By default, Apache does not permit the use of the .htaccess file. Therefore, you must activate the .htaccess file in your default virtual host configuration file.<\/p>\n\n\n\n<p>To accomplish this, modify the Apache default virtual host configuration file:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># nano \/etc\/apache2\/sites-available\/000-default.conf<\/pre>\n\n\n\n<p>Add the following:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Options Indexes FollowSymLinks MultiViews \nAllowOverride All\nRequire all granted<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>Save the file, then exit from the editor. And we need to restart the Apache service every time we make changes to apache configuration files.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># systemctl apache2 restart<\/pre>\n\n\n\n<p>At this point, the .htaccess file now overrides all other configurations, making URL rewrites possible.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">mod_rewrite Directives<\/h2>\n\n\n\n<p>The .htaccess file is where the URL rewriting operations take place and contains a number of directives. Several of the available directives are:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>The RewriteEngine engine controls whether the runtime is enabled or disabled. the following sentence structure:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-preformatted\">RewriteEngine On|Off<\/pre>\n\n\n\n<p>The RewriteEngine is not turned on by default. By turning the directive on or off, you can regulate runtime processing.<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li>The RewriteCond directive keeps track of the circumstances in which rewrites take place. Its syntax is as follows:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-preformatted\">RewriteCond String ConditionPattern [Flags]<\/pre>\n\n\n\n<p>The directive keyword for a single condition is RewriteCond. Before a single rule, several condition directives are available.<br>The String includes server variables and backreferences in addition to plain text.<br>The String is subject to ConditionPattern, a Pearl Compatible Regular Expression (PCRE).<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\">\n<li>The rewriting engine follows the RewriteRule rules. The syntax is as follows:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-preformatted\">RewriteRule Pattern Substitution [Flags]<\/pre>\n\n\n\n<p>The directive keyword for a single rule instance is RewriteRule. Order plays a key role, and there are multiple alternative rules.<br>Pattern is a regex pattern that matches a specific section of a URL request. The mod_rewrite module uses the Pearl Compatible Regular Expression (PCRE) syntax.<\/p>\n\n\n\n<p>The actual URL of the data we wish to display is substitution.<br>An optional parameter that modifies the behavior of the expression is [Flags].<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Examples of URL Rewriting<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Write Contents from One Page on Another<\/h3>\n\n\n\n<p>With the following URL rewriting, we can replace an existing page with new content without changing the URL.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">RewriteEngine On&lt;br&gt;RewriteRule ^oldpage.html$ newcontent.html [NC]<\/pre>\n\n\n\n<p>With just two lines above, when visitors access oldpage.html, they will see the content of newcontent.html instead.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Rewrite the URL<\/h3>\n\n\n\n<p>Now, let&#8217;s create an html file called home.html.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># nano \/var\/www\/html\/home.html<\/pre>\n\n\n\n<p>Paste the following.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;html&gt;\n    &lt;head&gt;\n        &lt;title&gt;Home&lt;\/title&gt;\n    &lt;\/head&gt;\n    &lt;body&gt;\n        &lt;h1&gt;Home Page&lt;\/h1&gt;\n\n&lt;h2&gt;This is the home page&lt;\/h2&gt;\n    &lt;\/body&gt;\n&lt;\/html&gt;<\/pre>\n\n\n\n<p>Save the file, then exit.<\/p>\n\n\n\n<p>Now, let&#8217;s create a .htaccess file<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># nano \/var\/www\/html\/.htaccess<\/pre>\n\n\n\n<p>Paste the following<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">RewriteEngine on&lt;br&gt;RewriteRule ^home$ home.html [NC]<\/pre>\n\n\n\n<p>Save the file, then exit.<\/p>\n\n\n\n<p>At this point, when you access http:\/\/YOUR_IP_ADDRESS\/home, you will see the content of http:\/\/YOUR_IP_ADDRESS\/home.html<\/p>\n\n\n\n<p>Hopefully, our guide on how to rewrite URLs with mod_rewrite for Apache on Ubuntu 22.04 was of help to you. We would love to hear from you now:<\/p>\n\n\n\n<p>Did we skip something essential, or do you need a more detailed explanation about any of the steps? What are some other topics or tutorials you would want us to delve into? <\/p>\n\n\n\n<p>Please, feel free to share your thoughts in the comment section.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The mod_rewrite is a module in Apache that utilizes a rule-based rewriting engine. It is employed for converting and redirecting the requested URL to a different URL.<\/p>\n","protected":false},"author":2,"featured_media":1911,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,208],"tags":[233,47],"class_list":["post-1863","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","category-ubuntu","tag-apache","tag-ubuntu"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 22.04 | LinuxCloudVPS Blog<\/title>\n<meta name=\"description\" content=\"The mod_rewrite is a module in Apache that utilizes a rule-based rewriting engine. It is employed for converting and redirecting the requested URL to a\" \/>\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.linuxcloudvps.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-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 22.04 | LinuxCloudVPS Blog\" \/>\n<meta property=\"og:description\" content=\"The mod_rewrite is a module in Apache that utilizes a rule-based rewriting engine. It is employed for converting and redirecting the requested URL to a\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.linuxcloudvps.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\/\" \/>\n<meta property=\"og:site_name\" content=\"LinuxCloudVPS Blog\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/www.facebook.com\/LinuxCloudVPS\" \/>\n<meta property=\"article:published_time\" content=\"2023-08-30T17:30:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.linuxcloudvps.com\/blog\/wp-content\/uploads\/2023\/08\/rewrite-urls-with-mod-rewrite-for-apache.webp\" \/>\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\/webp\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@LinuxCloudVPS\" \/>\n<meta name=\"twitter:site\" content=\"@LinuxCloudVPS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/#\\\/schema\\\/person\\\/ed907227ee7d151c617e6d0fe74f531a\"},\"headline\":\"How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 22.04\",\"datePublished\":\"2023-08-30T17:30:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\\\/\"},\"wordCount\":759,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/rewrite-urls-with-mod-rewrite-for-apache.webp\",\"keywords\":[\"apache\",\"ubuntu\"],\"articleSection\":[\"Tutorials\",\"Ubuntu\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\\\/\",\"url\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\\\/\",\"name\":\"How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 22.04 | LinuxCloudVPS Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/rewrite-urls-with-mod-rewrite-for-apache.webp\",\"datePublished\":\"2023-08-30T17:30:00+00:00\",\"description\":\"The mod_rewrite is a module in Apache that utilizes a rule-based rewriting engine. It is employed for converting and redirecting the requested URL to a\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/rewrite-urls-with-mod-rewrite-for-apache.webp\",\"contentUrl\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/rewrite-urls-with-mod-rewrite-for-apache.webp\",\"width\":742,\"height\":372,\"caption\":\"rewrite urls with mod rewrite for apache\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 22.04\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/\",\"name\":\"LinuxCloudVPS\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/#organization\",\"name\":\"LinuxCloudVPS\",\"url\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/logo.png\",\"contentUrl\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/logo.png\",\"width\":217,\"height\":25,\"caption\":\"LinuxCloudVPS\"},\"image\":{\"@id\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"http:\\\/\\\/www.facebook.com\\\/LinuxCloudVPS\",\"https:\\\/\\\/x.com\\\/LinuxCloudVPS\",\"http:\\\/\\\/www.linkedin.com\\\/company\\\/linuxcloudvps-com\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/#\\\/schema\\\/person\\\/ed907227ee7d151c617e6d0fe74f531a\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/?s=96&d=mm&r=g\",\"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\":\"admin\"},\"sameAs\":[\"http:\\\/\\\/www.linuxcloudvps.com\\\/\"],\"url\":\"https:\\\/\\\/www.linuxcloudvps.com\\\/blog\\\/author\\\/r0s3admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 22.04 | LinuxCloudVPS Blog","description":"The mod_rewrite is a module in Apache that utilizes a rule-based rewriting engine. It is employed for converting and redirecting the requested URL to a","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.linuxcloudvps.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\/","og_locale":"en_US","og_type":"article","og_title":"How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 22.04 | LinuxCloudVPS Blog","og_description":"The mod_rewrite is a module in Apache that utilizes a rule-based rewriting engine. It is employed for converting and redirecting the requested URL to a","og_url":"https:\/\/www.linuxcloudvps.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\/","og_site_name":"LinuxCloudVPS Blog","article_publisher":"http:\/\/www.facebook.com\/LinuxCloudVPS","article_published_time":"2023-08-30T17:30:00+00:00","og_image":[{"width":742,"height":372,"url":"https:\/\/www.linuxcloudvps.com\/blog\/wp-content\/uploads\/2023\/08\/rewrite-urls-with-mod-rewrite-for-apache.webp","type":"image\/webp"}],"author":"admin","twitter_card":"summary_large_image","twitter_creator":"@LinuxCloudVPS","twitter_site":"@LinuxCloudVPS","twitter_misc":{"Written by":"admin","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.linuxcloudvps.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\/#article","isPartOf":{"@id":"https:\/\/www.linuxcloudvps.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\/"},"author":{"name":"admin","@id":"https:\/\/www.linuxcloudvps.com\/blog\/#\/schema\/person\/ed907227ee7d151c617e6d0fe74f531a"},"headline":"How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 22.04","datePublished":"2023-08-30T17:30:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.linuxcloudvps.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\/"},"wordCount":759,"commentCount":0,"publisher":{"@id":"https:\/\/www.linuxcloudvps.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.linuxcloudvps.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\/#primaryimage"},"thumbnailUrl":"https:\/\/www.linuxcloudvps.com\/blog\/wp-content\/uploads\/2023\/08\/rewrite-urls-with-mod-rewrite-for-apache.webp","keywords":["apache","ubuntu"],"articleSection":["Tutorials","Ubuntu"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.linuxcloudvps.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.linuxcloudvps.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\/","url":"https:\/\/www.linuxcloudvps.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\/","name":"How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 22.04 | LinuxCloudVPS Blog","isPartOf":{"@id":"https:\/\/www.linuxcloudvps.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.linuxcloudvps.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\/#primaryimage"},"image":{"@id":"https:\/\/www.linuxcloudvps.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\/#primaryimage"},"thumbnailUrl":"https:\/\/www.linuxcloudvps.com\/blog\/wp-content\/uploads\/2023\/08\/rewrite-urls-with-mod-rewrite-for-apache.webp","datePublished":"2023-08-30T17:30:00+00:00","description":"The mod_rewrite is a module in Apache that utilizes a rule-based rewriting engine. It is employed for converting and redirecting the requested URL to a","breadcrumb":{"@id":"https:\/\/www.linuxcloudvps.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.linuxcloudvps.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.linuxcloudvps.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\/#primaryimage","url":"https:\/\/www.linuxcloudvps.com\/blog\/wp-content\/uploads\/2023\/08\/rewrite-urls-with-mod-rewrite-for-apache.webp","contentUrl":"https:\/\/www.linuxcloudvps.com\/blog\/wp-content\/uploads\/2023\/08\/rewrite-urls-with-mod-rewrite-for-apache.webp","width":742,"height":372,"caption":"rewrite urls with mod rewrite for apache"},{"@type":"BreadcrumbList","@id":"https:\/\/www.linuxcloudvps.com\/blog\/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-22-04\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.linuxcloudvps.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Rewrite URLs with mod_rewrite for Apache on Ubuntu 22.04"}]},{"@type":"WebSite","@id":"https:\/\/www.linuxcloudvps.com\/blog\/#website","url":"https:\/\/www.linuxcloudvps.com\/blog\/","name":"LinuxCloudVPS","description":"","publisher":{"@id":"https:\/\/www.linuxcloudvps.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.linuxcloudvps.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.linuxcloudvps.com\/blog\/#organization","name":"LinuxCloudVPS","url":"https:\/\/www.linuxcloudvps.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.linuxcloudvps.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.linuxcloudvps.com\/blog\/wp-content\/uploads\/2023\/08\/logo.png","contentUrl":"https:\/\/www.linuxcloudvps.com\/blog\/wp-content\/uploads\/2023\/08\/logo.png","width":217,"height":25,"caption":"LinuxCloudVPS"},"image":{"@id":"https:\/\/www.linuxcloudvps.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["http:\/\/www.facebook.com\/LinuxCloudVPS","https:\/\/x.com\/LinuxCloudVPS","http:\/\/www.linkedin.com\/company\/linuxcloudvps-com"]},{"@type":"Person","@id":"https:\/\/www.linuxcloudvps.com\/blog\/#\/schema\/person\/ed907227ee7d151c617e6d0fe74f531a","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g","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":"admin"},"sameAs":["http:\/\/www.linuxcloudvps.com\/"],"url":"https:\/\/www.linuxcloudvps.com\/blog\/author\/r0s3admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.linuxcloudvps.com\/blog\/wp-json\/wp\/v2\/posts\/1863","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.linuxcloudvps.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxcloudvps.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxcloudvps.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxcloudvps.com\/blog\/wp-json\/wp\/v2\/comments?post=1863"}],"version-history":[{"count":2,"href":"https:\/\/www.linuxcloudvps.com\/blog\/wp-json\/wp\/v2\/posts\/1863\/revisions"}],"predecessor-version":[{"id":1988,"href":"https:\/\/www.linuxcloudvps.com\/blog\/wp-json\/wp\/v2\/posts\/1863\/revisions\/1988"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.linuxcloudvps.com\/blog\/wp-json\/wp\/v2\/media\/1911"}],"wp:attachment":[{"href":"https:\/\/www.linuxcloudvps.com\/blog\/wp-json\/wp\/v2\/media?parent=1863"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxcloudvps.com\/blog\/wp-json\/wp\/v2\/categories?post=1863"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxcloudvps.com\/blog\/wp-json\/wp\/v2\/tags?post=1863"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}