{"id":4641,"date":"2020-04-03T16:30:54","date_gmt":"2020-04-03T16:30:54","guid":{"rendered":"https:\/\/lamp.ciscoar.com\/?page_id=4641"},"modified":"2020-04-24T18:58:50","modified_gmt":"2020-04-24T18:58:50","slug":"how-to-get-rid-of-index-php-in-wordpress-url","status":"publish","type":"page","link":"https:\/\/lamp.ciscoar.com\/?page_id=4641","title":{"rendered":"How to get rid of index.php in wordpress url"},"content":{"rendered":"\n\n\n<h2 class=\"wp-block-heading\">WordPress Permalinks<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Having <strong>index.php<\/strong> in your WordPress website URLs doesn\u2019t add any value to your visitors, it&#8217;s always better to have URLs as short as possible, we don&#8217;t want to distract our readers.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This change must be done <strong>immediately <\/strong>after your website goes online to make sure your site is indexed by search engines using the correct URL, the following animation shows you how to configure permalinks on WordPress.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1128\" height=\"656\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-permalinks-apache-centos7.gif\" alt=\"\" class=\"wp-image-4672\"\/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Permalinks common error<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If the above steps don&#8217;t make any effect in your URLs, and you get instead the following message, that means you&#8217;ll have to configure your <a href=\"\/installing-apache-on-centos-7\/\" target=\"_blank\" rel=\"noreferrer noopener\">Apache web server<\/a> before being able to modify the WordPress permalinks.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-permalinks-common-error_v2.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"413\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-permalinks-common-error_v2-1024x413.jpg\" alt=\"\" class=\"wp-image-4670\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-permalinks-common-error_v2-1024x413.jpg 1024w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-permalinks-common-error_v2-300x121.jpg 300w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-permalinks-common-error_v2-768x310.jpg 768w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-permalinks-common-error_v2.jpg 1438w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a><figcaption>WordPress permalink and .htaccess<\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">WordPress Directives<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The below image is just a zoom of the image above acting as an spotlight over the <strong>WordPress directives<\/strong> that have to be included in the &#8220;<strong>.htaccess<\/strong>&#8221; file.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-permalinks-common-error_v2_zoom.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"299\" height=\"194\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-permalinks-common-error_v2_zoom.jpg\" alt=\"\" class=\"wp-image-5036\"\/><\/a><figcaption>WordPress permalink recommended settings for the .htaccess file<\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1 &#8211; Enable mod_rewrite<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This particular topic was covered in the following article, feel free to go over it if you want to learn how to enable Apache mod_rewrite.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"\/how-to-enable-apache-mod_rewrite\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to enable Apache mod_rewrite<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2 &#8211; Enable .htaccess<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Be sure your <a href=\"\/apache-virtual-host-file\/\" target=\"_blank\" rel=\"noreferrer noopener\">Virtual Host file<\/a> is configured as shown in the following image.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-permalinks-common-error-enable-htaccess.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"614\" height=\"341\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-permalinks-common-error-enable-htaccess.jpg\" alt=\"\" class=\"wp-image-4663\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-permalinks-common-error-enable-htaccess.jpg 614w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-permalinks-common-error-enable-htaccess-300x167.jpg 300w\" sizes=\"auto, (max-width: 614px) 100vw, 614px\" \/><\/a><figcaption>&#8220;AllowOverride All&#8221; on the website (Virtual Host) root folder<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">I&#8217;ve highlighted the two lines that will enable new rules included in the &#8220;.htaccess&#8221; files to be applied.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3 &#8211; Copy and Paste the WordPress directives<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">As you&#8217;ve probably noticed, WordPress has already prepared the directives for us, they start with the tag &#8220;<strong>BEGIN WordPress<\/strong>&#8220;, and after a few comments (the lines which start with the pound symbol #) you&#8217;ll find the rules inside the IF module, immediately after the closing tag of the IF module you can see the &#8220;<strong>END WordPress<\/strong>&#8221; comment, see image below.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; gutter: false; highlight: [1,13]; title: ; notranslate\" title=\"\">\n# BEGIN WordPress\n# The directives (lines) between `BEGIN WordPress` and `END WordPress` are\n# dynamically generated, and should only be modified via WordPress filters.\n# Any changes to the directives between these markers will be overwritten.\n&amp;lt;IfModule mod_rewrite.c&gt;\nRewriteEngine On\nRewriteBase \/\nRewriteRule ^index\\.php$ - &#x5B;L]\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteCond %{REQUEST_FILENAME} !-d\nRewriteRule . \/index.php &#x5B;L]\n&amp;lt;\/IfModule&gt;\n# END WordPress\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">Step 4 &#8211; .htaccess file location<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This file is located in the root folder of your website, if the <strong><a href=\"\/installing-wordpress\/#WordPressorg_recommends_the_following\" target=\"_blank\" rel=\"noreferrer noopener\">ownership and permissions<\/a><\/strong> are configured properly, then WordPress shouldn&#8217;t have any problem to write the &#8220;<strong>.htaccess<\/strong>&#8221; file automatically.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/htaccess-path-graphical-2.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"706\" height=\"253\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/htaccess-path-graphical-2.jpg\" alt=\"\" class=\"wp-image-4690\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/htaccess-path-graphical-2.jpg 706w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/htaccess-path-graphical-2-300x108.jpg 300w\" sizes=\"auto, (max-width: 706px) 100vw, 706px\" \/><\/a><\/figure><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"rest\" class=\"language-rest\">\/var\/www\/example.com\/public_html\/.htaccess<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5 &#8211; .htaccess ownership and permissions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you followed the best practices about Ownership and Permissions for the .htaccess file, your file must look like in the following screenshots.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">From the CLI you can use the list command as follow:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"vim\" class=\"language-vim\">ls -la .htaccess<\/code><\/pre>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/htaccess-path-cli.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"535\" height=\"126\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/htaccess-path-cli.jpg\" alt=\"\" class=\"wp-image-4693\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/htaccess-path-cli.jpg 535w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/htaccess-path-cli-300x71.jpg 300w\" sizes=\"auto, (max-width: 535px) 100vw, 535px\" \/><\/a><figcaption>.htaccess file location, ownership and permissions<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Using the GUI provided by WinSCP you must see the following.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/htaccess-octal0600permissions-apache-owner.png\"><img loading=\"lazy\" decoding=\"async\" width=\"374\" height=\"458\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/htaccess-octal0600permissions-apache-owner.png\" alt=\"\" class=\"wp-image-4726\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/htaccess-octal0600permissions-apache-owner.png 374w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/htaccess-octal0600permissions-apache-owner-245x300.png 245w\" sizes=\"auto, (max-width: 374px) 100vw, 374px\" \/><\/a><figcaption>.htaccess file ownership and permissions<\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Problem solved<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">That&#8217;s it, if <strong>mod_rewite<\/strong> is enabled and both the <a rel=\"noreferrer noopener\" href=\"\/apache-virtual-host-file\/\" target=\"_blank\">virtual host configuration file<\/a> and the <strong>.htaccess<\/strong> file ownership and permissions are configured correctly, then WordPress will take care of everything creating the rules and also applying them, every time you decide to change your website permalink settings.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WordPress Permalinks Having index.php in your WordPress website URLs doesn\u2019t add any value to your visitors, it&#8217;s always better to have URLs as short as possible, we don&#8217;t want to distract our readers. This change must be done immediately after your website goes online to make sure your site is indexed by search engines using &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/lamp.ciscoar.com\/?page_id=4641\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to get rid of index.php in wordpress url&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-4641","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/pages\/4641","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4641"}],"version-history":[{"count":75,"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/pages\/4641\/revisions"}],"predecessor-version":[{"id":5113,"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/pages\/4641\/revisions\/5113"}],"wp:attachment":[{"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4641"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}