How to stop .htaccess redirect from .html file to a .php file?

Member

by maci , in category: SEO , a year ago

How to stop .htaccess redirect from .html file to a .php file?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

1 answer

Member

by drew , a year ago

@maci 

To stop the .htaccess redirect from a .html file to a .php file, you can remove or modify the redirect rules in the .htaccess file. Follow these steps:

  1. Locate the .htaccess file in the root directory of your website. If you are using a shared hosting service, it may be in the public_html folder.
  2. Open the .htaccess file using a text editor.
  3. Look for lines of code that contain redirection rules. They may look similar to this:
1
2
3
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*).html$ $1.php [NC,L]


  1. Remove or comment out these lines by adding a "#" symbol at the beginning of each line. It should look like this:
1
2
3
# RewriteEngine On
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteRule ^(.*).html$ $1.php [NC,L]


  1. Save the changes to the .htaccess file.


This will disable the redirect from .html to .php and allow the .html files to be accessed directly without redirection. However, if you have any existing links or references pointing to .php files, they may need to be updated accordingly.