<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>#HTAccess &#8211; Aveshost Blog</title>
	<atom:link href="https://blog.aveshost.com/tag/htaccess/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.aveshost.com</link>
	<description>Your Blueprint for Online Success</description>
	<lastBuildDate>Fri, 02 Jan 2026 23:58:46 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.1</generator>

<image>
	<url>https://blog.aveshost.com/wp-content/uploads/2026/01/logo-150x150.png</url>
	<title>#HTAccess &#8211; Aveshost Blog</title>
	<link>https://blog.aveshost.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Remove Public From Laravel URL (4 Easy Methods)</title>
		<link>https://blog.aveshost.com/how-to-remove-public-from-laravel-url/</link>
					<comments>https://blog.aveshost.com/how-to-remove-public-from-laravel-url/#respond</comments>
		
		<dc:creator><![CDATA[Kennedy Dzigbenyo]]></dc:creator>
		<pubDate>Sat, 08 Feb 2025 15:28:51 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[#CleanURLs]]></category>
		<category><![CDATA[#HTAccess]]></category>
		<category><![CDATA[#Laravel]]></category>
		<guid isPermaLink="false">https://blog.aveshost.com/?p=2898</guid>

					<description><![CDATA[Fix Laravel URLs: Remove Public from Your Website Address When you install Laravel on your server or localhost, you might notice that your project URL includes /public, like this: This happens because Laravel places its main entry point inside the public folder for security reasons. However, having /public in the URL looks unprofessional and is [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading" id="fix-laravel-ur-ls-remove-public-from-your-website-address">Fix Laravel URLs: Remove Public from Your Website Address</h2>



<p class="wp-block-paragraph">When you install Laravel on your server or localhost, you might notice that your project URL includes <code>/public</code>, like this:</p>



<pre class="wp-block-code"><code>http:&#47;&#47;example.com/public</code></pre>



<p class="wp-block-paragraph">This happens because Laravel places its main entry point inside the <code>public</code> folder for security reasons. However, having <code>/public</code> in the URL looks unprofessional and is not user-friendly. </p>



<div class="wp-block-rank-math-toc-block" id="rank-math-toc"><h2>Table of Contents</h2><nav><div><div><a href="#fix-laravel-ur-ls-remove-public-from-your-website-address">Fix Laravel URLs: Remove Public from Your Website Address</a></div><div><a href="#why-does-laravel-include-the-public-directory-in-the-url">Why Does Laravel Include the /public Directory in the URL?</a></div><div><a href="#method-1-move-contents-of-public-folder-to-root-not-recommended">Method 1: Move Contents of Public Folder to Root (Not Recommended)</a></div><div><a href="#method-2-use-an-htaccess-file-recommended-for-shared-hosting">Method 2: Use an .htaccess File (Recommended for Shared Hosting)</a></div><div><a href="#method-3-change-the-document-root-in-c-panel-or-apache-configuration">Method 3: Change the Document Root in cPanel or Apache Configuration</a></div><div><a href="#method-4-create-a-symbolic-link-advanced-users">Method 4: Create a Symbolic Link (Advanced Users)</a></div><div><a href="#conclusion">Conclusion</a></div><div><a href="#fa-qs-on-how-to-remove-public-from-laravel-url">FAQs on How to Remove /public from Laravel URL</a></div></div></nav></div>



<p class="wp-block-paragraph">In this guide, I’ll show you step-by-step how to remove <code>/public</code> from your Laravel URL properly and securely.</p>



<p class="wp-block-paragraph"><strong>Suggested Reading:</strong> <a href="https://blog.aveshost.com/how-to-deploy-laravel-project-on-cpanel/">How to Deploy Laravel Project on cPanel</a></p>



<h2 class="wp-block-heading" id="why-does-laravel-include-the-public-directory-in-the-url">Why Does Laravel Include the /public Directory in the URL?</h2>



<p class="wp-block-paragraph">Laravel is designed with security in mind. The <code>public</code> directory is the only folder that should be directly accessible by users because it contains the front-facing assets like CSS, JavaScript, and index.php. Meanwhile, the rest of the Laravel application (controllers, models, views, and configuration files) remains secure outside the web root to prevent direct access.</p>



<p class="wp-block-paragraph">Now, let’s dive into different methods to remove <code>/public</code> from your Laravel URL.</p>



<h2 class="wp-block-heading" id="method-1-move-contents-of-public-folder-to-root-not-recommended">Method 1: Move Contents of Public Folder to Root (Not Recommended)</h2>



<p class="wp-block-paragraph">A quick but risky way to remove <code>/public</code> from the URL is to move all files inside the <code>public</code> folder directly into your root Laravel directory. However, this method is not recommended because it exposes your application files to potential security threats.</p>



<p class="wp-block-paragraph">If you still want to proceed, follow these steps:</p>



<ol start="1" class="wp-block-list">
<li>Move everything inside the <code>public</code> folder (except <code>.htaccess</code>) to the root folder.</li>



<li>Open the <code>index.php</code> file and modify these lines:</li>
</ol>



<pre class="wp-block-code"><code>require __DIR__.'/../bootstrap/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';</code></pre>



<p class="wp-block-paragraph">Change them to:</p>



<pre class="wp-block-code"><code>require __DIR__.'/bootstrap/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';</code></pre>



<p class="wp-block-paragraph"><strong><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/26a0.png" alt="⚠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Warning:</strong> While this works, it is not safe because it exposes critical Laravel directories like <code>routes</code>, <code>storage</code>, and <code>config</code> to the public. Avoid using this method unless absolutely necessary.</p>



<h2 class="wp-block-heading" id="method-2-use-an-htaccess-file-recommended-for-shared-hosting">Method 2: Use an .htaccess File (Recommended for Shared Hosting)</h2>



<p class="wp-block-paragraph">The best way to remove <code>/public</code> from your Laravel URL is by using an <code>.htaccess</code> file. This method is safe and works well on shared hosting environments like cPanel.</p>



<h3 class="wp-block-heading" id="steps-to-use-htaccess-to-remove-public-from-url"><strong>Steps to Use .htaccess to Remove /public from URL</strong></h3>



<ul class="wp-block-list">
<li><strong>Create or edit the .htaccess file in the root Laravel folder.</strong></li>



<li>Add the following rewrite rules:</li>
</ul>



<pre class="wp-block-code"><code>&lt;IfModule mod_rewrite.c&gt;
    RewriteEngine On
    RewriteRule ^(.*)$ public/$1 &#91;L]
&lt;/IfModule&gt;</code></pre>



<ul class="wp-block-list">
<li>Save the file and upload it to your server (if applicable).</li>
</ul>



<p class="wp-block-paragraph">Now, when you visit <code>http://example.com</code>, it will automatically serve the Laravel application without requiring <code>/public</code> in the URL.</p>



<h2 class="wp-block-heading" id="method-3-change-the-document-root-in-c-panel-or-apache-configuration">Method 3: Change the Document Root in cPanel or Apache Configuration</h2>



<p class="wp-block-paragraph">If you have full control over your hosting environment (such as VPS or Dedicated servers), a cleaner solution is to change your server’s document root to the <code>public</code> folder.</p>



<h3 class="wp-block-heading" id="for-c-panel-users">For cPanel Users</h3>



<ol start="1" class="wp-block-list">
<li>Log into <strong>cPanel</strong> and go to <strong>Domains</strong> &gt; <strong>Manage</strong>.</li>



<li>Locate your domain and find the <strong>Document Root</strong> section.</li>



<li>Change the document root from <code>/home/youruser/public_html/</code> to <code>/home/youruser/public_html/public</code>.</li>



<li>Save the changes and restart Apache if necessary.</li>
</ol>



<h3 class="wp-block-heading" id="for-apache-users-vps-dedicated-server">For Apache Users (VPS/Dedicated Server)</h3>



<ol start="1" class="wp-block-list">
<li>Open your Apache configuration file (<code>httpd.conf</code> or your virtual host file).</li>



<li>Find the <code>&lt;VirtualHost&gt;</code> block for your domain and update the <code>DocumentRoot</code>:</li>
</ol>



<pre class="wp-block-code"><code>DocumentRoot "/var/www/html/public"
&lt;Directory "/var/www/html/public"&gt;
    AllowOverride All
    Require all granted
&lt;/Directory&gt;</code></pre>



<ol start="3" class="wp-block-list">
<li>Save the file and restart Apache:</li>
</ol>



<pre class="wp-block-code"><code>sudo systemctl restart apache2</code></pre>



<h3 class="wp-block-heading" id="for-nginx-users">For Nginx Users</h3>



<ol start="1" class="wp-block-list">
<li>Open your Nginx configuration file:</li>
</ol>



<pre class="wp-block-code"><code>sudo nano /etc/nginx/sites-available/default</code></pre>



<ol start="2" class="wp-block-list">
<li>Change the <code>root</code> directive:</li>
</ol>



<pre class="wp-block-code"><code>root /var/www/html/public;</code></pre>



<ol start="3" class="wp-block-list">
<li>Save the file and restart Nginx:</li>
</ol>



<pre class="wp-block-code"><code>sudo systemctl restart nginx</code></pre>



<p class="wp-block-paragraph">This method ensures that your Laravel app loads correctly without needing an <code>.htaccess</code> workaround.</p>



<h2 class="wp-block-heading" id="method-4-create-a-symbolic-link-advanced-users">Method 4: Create a Symbolic Link (Advanced Users)</h2>



<p class="wp-block-paragraph">Another clean way to remove <code>/public</code> is by creating a <a href="https://en.wikipedia.org/wiki/Symbolic_link" rel="noopener">symbolic link</a> that points the <code>public_html</code> folder to the Laravel <code>public</code> directory.</p>



<h3 class="wp-block-heading" id="steps-to-create-a-symbolic-link">Steps to Create a Symbolic Link</h3>



<ol start="1" class="wp-block-list">
<li>Backup your current <code>html</code> directory:</li>
</ol>



<pre class="wp-block-code"><code>mv html html_backup</code></pre>



<ol start="2" class="wp-block-list">
<li>Create a symbolic link from <code>html</code> to Laravel’s <code>public</code> folder:</li>
</ol>



<pre class="wp-block-code"><code>ln -s /home/youruser/laravel_project/public /home/youruser/html</code></pre>



<ol start="3" class="wp-block-list">
<li>Verify the symbolic link:</li>
</ol>



<pre class="wp-block-code"><code>ls -l /home/youruser/html</code></pre>



<p class="wp-block-paragraph">This approach keeps your Laravel structure intact while making the public files accessible through <code>html</code>.</p>



<h2 class="wp-block-heading" id="conclusion">Conclusion</h2>



<p class="wp-block-paragraph">Removing <code>/public</code> from your Laravel URL is essential for a professional-looking and user-friendly website. Depending on your hosting setup, you can use:</p>



<p class="wp-block-paragraph"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>.htaccess Rewrite Rules</strong> – Best for <a href="https://www.aveshost.com/web-hosting" rel="noopener">shared hosting</a> and quick fixes.<br><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Changing Document Root</strong> – Ideal for cPanel, <a href="https://www.aveshost.com/self-managed-vps-hosting" rel="noopener">VPS</a>, or <a href="https://www.aveshost.com/self-managed-dedicated-hosting" rel="noopener">dedicated servers</a>.<br><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Creating a Symbolic Link</strong> – Useful for keeping Laravel’s structure clean.</p>



<p class="wp-block-paragraph">Avoid moving files out of the <code>public</code> directory, as it poses security risks.</p>



<p class="wp-block-paragraph">I hope this guide helps you set up your Laravel project the right way! If you have any questions, reach out to <a href="https://www.aveshost.com/support" rel="noopener">Aveshost support</a> or drop a comment below. <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f680.png" alt="🚀" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<p class="wp-block-paragraph">Happy Coding!</p>



<p class="wp-block-paragraph"><strong>Suggested Reading:</strong></p>



<ul class="wp-block-list">
<li><a href="https://blog.aveshost.com/how-to-remove-html-php-from-urls/">How to Remove .html, .php, or Both from URLs</a></li>



<li><a href="https://blog.aveshost.com/how-to-buy-cpanel-hosting/">How to Buy cPanel Hosting for Your Website: Beginner’s Guide</a></li>



<li><a href="https://my.aveshost.com/knowledgebase/22/How-to-Install-an-SSL-Certificate-in-cPanel-.html" rel="noopener">How to Install an SSL Certificate in cPanel</a></li>



<li><a href="https://blog.aveshost.com/how-to-set-up-postgresql-database-in-cpanel/">How to Set Up a PostgreSQL Database and User in cPanel</a></li>



<li><a href="https://blog.aveshost.com/how-to-set-up-mysql-database-in-cpanel/">How to Set Up a MySQL Database &amp; User in cPanel (2 Easy Methods)</a></li>



<li><a href="https://blog.aveshost.com/how-to-flush-dns/">How to Flush DNS Cache on Windows, Mac, Linux &amp; Browsers</a></li>
</ul>



<h2 class="wp-block-heading" id="fa-qs-on-how-to-remove-public-from-laravel-url">FAQs on How to Remove /public from Laravel URL</h2>


<div id="rank-math-faq" class="rank-math-block">
<div class="rank-math-list ">
<div id="rm-faq-9c4c795558e6e9e1e638a3dfe289b8c0" class="rank-math-list-item">
<h3 class="rank-math-question ">Why does Laravel include /public in the URL by default?</h3>
<div class="rank-math-answer ">

<p>Laravel includes /public in the URL for security reasons. The public directory is the only folder that should be directly accessible by users because it contains front-facing assets like CSS, JavaScript, and index.php, while keeping the rest of the application (controllers, models, views, configuration) secure outside the web root.</p>

</div>
</div>
<div id="rm-faq-262dd147399fbd7ba84242b61c76b952" class="rank-math-list-item">
<h3 class="rank-math-question ">What is the recommended method to remove /public from Laravel URL on shared hosting?</h3>
<div class="rank-math-answer ">

<p>The recommended method for shared hosting is using an .htaccess file. Create or edit the .htaccess file in the root Laravel folder and add rewrite rules to redirect all requests to the public directory, which safely removes /public from the URL without exposing application files.</p>

</div>
</div>
<div id="rm-faq-7277bafbb5a56e09f6d508b476869a3c" class="rank-math-list-item">
<h3 class="rank-math-question ">How can I remove /public from Laravel URL by changing the document root?</h3>
<div class="rank-math-answer ">

<p>You can change the document root to point directly to the public folder. In cPanel, go to Domains &gt; Manage and update the document root to include /public. For Apache or Nginx servers, modify the configuration file to set the document root to the public directory and restart the web server.</p>

</div>
</div>
<div id="rm-faq-1ed2d94d500c4e26593e4069c3d1e4c8" class="rank-math-list-item">
<h3 class="rank-math-question ">Is moving public folder contents to root directory a safe method?</h3>
<div class="rank-math-answer ">

<p>No, moving public folder contents to the root directory is not recommended and poses security risks. This method exposes critical Laravel directories like routes, storage, and config to public access, making your application vulnerable to attacks. It should only be used as a last resort.</p>

</div>
</div>
<div id="rm-faq-34a33601179c58e507a89cf44f4d03aa" class="rank-math-list-item">
<h3 class="rank-math-question ">What is the symbolic link method for removing /public from URL?</h3>
<div class="rank-math-answer ">

<p>The symbolic link method involves creating a link that points your web server&#8217;s document root (like public_html) to Laravel&#8217;s public directory. This keeps the Laravel structure intact while making public files accessible without /public in the URL. It&#8217;s a clean solution for advanced users with server access.</p>

</div>
</div>
</div>
</div>]]></content:encoded>
					
					<wfw:commentRss>https://blog.aveshost.com/how-to-remove-public-from-laravel-url/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Remove .html, .php, or Both from URLs</title>
		<link>https://blog.aveshost.com/how-to-remove-html-php-from-urls/</link>
					<comments>https://blog.aveshost.com/how-to-remove-html-php-from-urls/#respond</comments>
		
		<dc:creator><![CDATA[James Wilson]]></dc:creator>
		<pubDate>Wed, 05 Feb 2025 17:12:23 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[#CleanURLs]]></category>
		<category><![CDATA[#HTAccess]]></category>
		<category><![CDATA[#RemoveHTML]]></category>
		<category><![CDATA[#RemovePHP]]></category>
		<category><![CDATA[#URLOptimization]]></category>
		<guid isPermaLink="false">https://blog.aveshost.com/?p=2871</guid>

					<description><![CDATA[How to Remove .html and .php File Extensions from URLs Having clean and user-friendly URLs is essential for improving website navigation and SEO. By removing file extensions like .html and .php, you can create shorter, more readable URLs that enhance user experience and look more professional. Additionally, search engines prefer concise URLs, which can contribute [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading" id="how-to-remove-html-and-php-file-extensions-from-ur-ls">How to Remove .html and .php File Extensions from URLs</h2>



<p class="wp-block-paragraph">Having clean and user-friendly URLs is essential for improving website navigation and SEO. By removing file extensions like <strong>.html</strong> and <strong>.php</strong>, you can create shorter, more readable URLs that enhance user experience and look more professional. Additionally, search engines prefer concise URLs, which can contribute to better rankings.</p>



<div class="wp-block-rank-math-toc-block" id="rank-math-toc"><h2>Table of Contents</h2><nav><div><div><a href="#how-to-remove-html-and-php-file-extensions-from-ur-ls">How to Remove .html and .php File Extensions from URLs</a></div><div><a href="#&#x1f539;-step-1-check-if-htaccess-exists"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f539.png" alt="🔹" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 1: Check if .htaccess Exists</a></div><div><a href="#&#x1f539;-step-2-remove-html-from-ur-ls"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f539.png" alt="🔹" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 2: Remove .html from URLs</a></div><div><a href="#&#x1f539;-step-3-remove-php-from-ur-ls"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f539.png" alt="🔹" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 3: Remove .php from URLs</a></div><div><a href="#&#x1f539;-step-4-remove-both-html-and-php"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f539.png" alt="🔹" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 4: Remove Both .html and .php</a></div><div><a href="#&#x1f539;-step-5-update-internal-links"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f539.png" alt="🔹" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 5: Update Internal Links</a></div><div><a href="#&#x1f539;-step-6-clear-cache-and-test"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f539.png" alt="🔹" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 6: Clear Cache and Test</a></div><div><a href="#&#x2705;-conclusion"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Conclusion</a></div><div><a href="#frequently-asked-questions-fa-qs">Frequently Asked Questions (FAQs)</a></div></div></nav></div>



<p class="wp-block-paragraph">In this guide, we’ll walk you through the step-by-step process to remove file extensions from URLs using <strong>.htaccess</strong>. Whether you want to remove only <strong>.html</strong>, only <strong>.php</strong>, or both, we&#8217;ve got you covered.</p>



<p class="wp-block-paragraph">Here’s what we’ll cover:<br><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> How to remove <strong>.html</strong> file extensions<br><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> How to remove <strong>.php</strong> file extensions<br><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> How to remove <strong>both .html and .php</strong> extensions for a cleaner URL structure</p>



<p class="wp-block-paragraph">By the end of this guide, your website URLs will look cleaner, more professional, and easier to remember! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f680.png" alt="🚀" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<h2 class="wp-block-heading" id="&#x1f539;-step-1-check-if-htaccess-exists"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f539.png" alt="🔹" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 1: Check if <code>.htaccess</code> Exists</h2>



<p class="wp-block-paragraph">Before making changes, ensure your website is running on an Apache server with <code>mod_rewrite</code> enabled.</p>



<ol class="wp-block-list">
<li>Go to your website’s root directory (e.g., <code>public_html</code>).</li>



<li>Look for a file named <code>.htaccess</code>.
<ul class="wp-block-list">
<li>If it exists, edit it.</li>



<li>If not, create a new file named <code>.htaccess</code>.</li>
</ul>
</li>
</ol>



<h2 class="wp-block-heading" id="&#x1f539;-step-2-remove-html-from-ur-ls"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f539.png" alt="🔹" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 2: Remove <code>.html</code> from URLs</h2>



<p class="wp-block-paragraph">To remove <code>.html</code> extensions and make URLs cleaner, add the following code to your <code>.htaccess</code> file:</p>



<pre class="wp-block-code"><code>RewriteEngine On

# Redirect .html URLs to clean URLs (for SEO)
RewriteCond %{THE_REQUEST} ^&#91;A-Z]{3,}\s(&#91;^.]+)\.html\sHTTP &#91;NC]
RewriteRule ^ %1 &#91;R=301,L]

# Serve .html files without typing .html
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html &#91;NC,L]
</code></pre>



<p class="wp-block-paragraph"><strong><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4cc.png" alt="📌" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Example:</strong></p>



<ul class="wp-block-list">
<li><code>yourdomainname.com/about.html</code> → <code>yourdomainname.com/about</code></li>



<li><code>yourdomainname.com/contact.html</code> → <code>yourdomainname.com/contact</code></li>
</ul>



<h2 class="wp-block-heading" id="&#x1f539;-step-3-remove-php-from-ur-ls"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f539.png" alt="🔹" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 3: Remove <code>.php</code> from URLs</h2>



<p class="wp-block-paragraph">To remove <code>.php</code> extensions, add this to your <code>.htaccess</code> file:</p>



<pre class="wp-block-code"><code>RewriteEngine On

# Redirect .php URLs to clean URLs (for SEO)
RewriteCond %{THE_REQUEST} ^&#91;A-Z]{3,}\s(&#91;^.]+)\.php\sHTTP &#91;NC]
RewriteRule ^ %1 &#91;R=301,L]

# Serve .php files without typing .php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php &#91;NC,L]
</code></pre>



<p class="wp-block-paragraph"><strong><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4cc.png" alt="📌" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Example:</strong></p>



<ul class="wp-block-list">
<li><code>yourdomainname.com/about.php</code> → <code>yourdomainname.com/about</code></li>



<li><code>yourdomainname.com/contact.php</code> → <code>yourdomainname.com/contact</code></li>
</ul>



<h2 class="wp-block-heading" id="&#x1f539;-step-4-remove-both-html-and-php"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f539.png" alt="🔹" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 4: Remove Both <code>.html</code> and <code>.php</code></h2>



<p class="wp-block-paragraph">If your website has both <code>.html</code> and <code>.php</code> files and you want to remove both extensions, use this:</p>



<pre class="wp-block-code"><code>RewriteEngine On

# Redirect .html and .php URLs to clean URLs (for SEO)
RewriteCond %{THE_REQUEST} ^&#91;A-Z]{3,}\s(&#91;^.]+)\.(html|php)\sHTTP &#91;NC]
RewriteRule ^ %1 &#91;R=301,L]

# Serve files without .html or .php in the URL
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html &#91;NC,L]

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php &#91;NC,L]
</code></pre>



<p class="wp-block-paragraph"><strong><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4cc.png" alt="📌" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Example:</strong></p>



<ul class="wp-block-list">
<li><code>yourdomainname.com/about.html</code> → <code>yourdomainname.com/about</code></li>



<li><code>yourdomainname.com/about.php</code> → <code>yourdomainname.com/about</code></li>
</ul>



<h2 class="wp-block-heading" id="&#x1f539;-step-5-update-internal-links"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f539.png" alt="🔹" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 5: Update Internal Links</h2>



<p class="wp-block-paragraph">Now that your URLs no longer require <strong>.html</strong> or <strong>.php</strong>, it&#8217;s essential to update all internal links throughout your website.</p>



<p class="wp-block-paragraph"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Manually Update Links</strong> – Go through your <strong>HTML, PHP, or database</strong> links and remove <code>.html</code> or <code>.php</code> where necessary.</p>



<p class="wp-block-paragraph"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Update Navigation Menus</strong> – If your website has navigation menus or buttons linking to pages with file extensions, modify them to use the new clean URLs.</p>



<p class="wp-block-paragraph"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Check Dynamic Links</strong> – If your site dynamically generates links (e.g., via a CMS or PHP scripts), ensure they point to URLs <strong>without file extensions</strong>.</p>



<p class="wp-block-paragraph">By updating all internal links, you ensure a smooth browsing experience and avoid broken links. </p>



<ul class="wp-block-list">
<li>Change this:</li>
</ul>



<pre class="wp-block-code"><code>&lt;a href="about.html"&gt;About&lt;/a&gt;</code></pre>



<ul class="wp-block-list">
<li>To this:</li>
</ul>



<pre class="wp-block-code"><code>&lt;a href="about"&gt;About&lt;/a&gt;</code></pre>



<h2 class="wp-block-heading" id="&#x1f539;-step-6-clear-cache-and-test"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f539.png" alt="🔹" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 6: Clear Cache and Test</h2>



<ul class="wp-block-list">
<li><strong>Clear your browser cache.</strong></li>



<li><strong>Restart Apache (if needed):</strong></li>
</ul>



<pre class="wp-block-code"><code>systemctl restart apache2  # Ubuntu/Debian
systemctl restart httpd    # CentOS/RHEL
</code></pre>



<ul class="wp-block-list">
<li><strong>Test your new URLs!</strong></li>
</ul>



<h2 class="wp-block-heading" id="&#x2705;-conclusion"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Conclusion</h2>



<p class="wp-block-paragraph">By following these steps, you have successfully removed <strong>.html</strong> and <strong>.php</strong> file extensions from your URLs, making them cleaner and more user-friendly. This small yet impactful change enhances your website&#8217;s <strong>SEO</strong>, improves <strong>user experience</strong>, and makes your links easier to read and remember.</p>



<p class="wp-block-paragraph">Clean URLs contribute to a more professional web presence, and search engines tend to favor shorter, keyword-rich URLs. Now, your website looks more modern, structured, and optimized for both visitors and search engines. <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f680.png" alt="🚀" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<p class="wp-block-paragraph">If you have any questions or need further assistance, let us know in the comments or feel free to reach out to <a href="https://www.aveshost.com/support" rel="noopener">Aveshost Support! </a></p>



<p class="wp-block-paragraph">Happy optimizing! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f60a.png" alt="😊" class="wp-smiley" style="height: 1em; max-height: 1em;" />&nbsp;</p>



<p class="wp-block-paragraph"><strong>Suggested Reading:</strong></p>



<ul class="wp-block-list">
<li><a href="https://my.aveshost.com/knowledgebase/22/How-to-Install-an-SSL-Certificate-in-cPanel-.html" target="_blank" rel="noreferrer noopener">How to Install an SSL Certificate in cPanel&nbsp;</a></li>



<li><a href="https://blog.aveshost.com/how-to-flush-dns/">How to Flush DNS Cache on Windows, Mac, Linux &amp; Browsers</a></li>



<li><a href="https://blog.aveshost.com/how-to-set-up-mysql-database-in-cpanel/">How to Set Up a MySQL Database &amp; User in cPanel (2 Easy Methods)</a></li>



<li><a href="https://blog.aveshost.com/how-to-buy-cpanel-hosting/">How to Buy cPanel Hosting for Your Website: Beginner’s Guide</a></li>



<li><a href="https://blog.aveshost.com/how-to-set-up-postgresql-database-in-cpanel/">How to Set Up a PostgreSQL Database and User in cPanel</a></li>
</ul>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading" id="frequently-asked-questions-fa-qs">Frequently Asked Questions (FAQs)</h2>


<div id="rank-math-faq" class="rank-math-block">
<div class="rank-math-list ">
<div id="rm-faq-78f4bc8d9c395d0644a4d2ca9665d8ae" class="rank-math-list-item">
<h3 class="rank-math-question ">Why should I remove .html and .php extensions from my URLs?</h3>
<div class="rank-math-answer ">

<p>Removing file extensions creates cleaner, shorter, and more readable URLs that improve user experience, look more professional, and are preferred by search engines for better SEO rankings.</p>

</div>
</div>
<div id="rm-faq-c985b49e6660ccc95a6dc9c98592b1ef" class="rank-math-list-item">
<h3 class="rank-math-question ">What do I need before removing file extensions from URLs?</h3>
<div class="rank-math-answer ">

<p>You need an Apache web server with mod_rewrite enabled and access to your website&#8217;s root directory to create or edit the .htaccess file.</p>

</div>
</div>
<div id="rm-faq-2b391a71ba202eafd30fc28a787b77fb" class="rank-math-list-item">
<h3 class="rank-math-question ">How do I remove both .html and .php extensions at once?</h3>
<div class="rank-math-answer ">

<p>Add specific rewrite rules to your .htaccess file that redirect both .html and .php URLs to clean versions, then update all internal links throughout your website to remove the extensions.</p>

</div>
</div>
<div id="rm-faq-efb8c4d818b2ca59959c46d0fe11a6c5" class="rank-math-list-item">
<h3 class="rank-math-question ">What should I do after removing file extensions from URLs?</h3>
<div class="rank-math-answer ">

<p>Update all internal links (HTML, PHP, navigation menus, and dynamic links), clear your browser cache, restart Apache if needed, and thoroughly test your new URLs to ensure they work properly.</p>

</div>
</div>
</div>
</div>]]></content:encoded>
					
					<wfw:commentRss>https://blog.aveshost.com/how-to-remove-html-php-from-urls/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
