remove html htm

Discuss Search Engine Optimization in relation to Joomla! 3.x. This forum will also have discussions on SEF/SEO Joomla! 3.x extensions.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
whitetigeritaly
Joomla! Intern
Joomla! Intern
Posts: 77
Joined: Sun Apr 15, 2012 11:34 am
Location: Milan, Italy
Contact:

remove html htm

Post by whitetigeritaly » Thu May 26, 2016 3:17 pm

My website can be reached without html/htm/php extension.
It was published and signaled in this format.

For some reason I do not know, I see reported errors 404 related to pages with the correct name, but which have the extension.
So I wanted to create rules in .htaccess to remove extensions, but I keep getting errors.
Where am I wrong?

Code: Select all

...
# Remove .php-extension from url
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME}\.php -f
  RewriteRule ^([^\.]+)/$ $1.php

# Remove .htm-extension from url
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME}\.htm -f
  RewriteRule ^([^\.]+)/$ $1.htm

# Remove .html-extension from url
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME}\.html -f
  RewriteRule ^([^\.]+)/$ $1.html
  ...
  
Thanks in advance

sozzled
I've been banned!
Posts: 13639
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: remove html htm

Post by sozzled » Thu May 26, 2016 7:48 pm

I'm guessing that your site pages look something like http://<site-URL>/<menu-item>/xxxxxx.htm

Is that right?

Unisoftdev
Joomla! Apprentice
Joomla! Apprentice
Posts: 49
Joined: Mon Feb 22, 2016 4:58 am
Location: London, UK
Contact:

Re: remove html htm

Post by Unisoftdev » Sun May 29, 2016 1:54 pm

Are you using Apache, LiteSpeed, Nginx, or whatsoever?

.php

Code: Select all

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
.html

Code: Select all

RewriteRule ^([^/.]+)$ $1.html [L]
and you can use as well:

Code: Select all

RewriteRule ^([^\.]+)$ $1.html [NC,L]
Then completely:

Code: Select all

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

RewriteRule ^([^/.]+)$ $1.html [L]

RewriteRule ^([^/.]+)$ $1.htm [L]
If you're using only [L], it will be not accessible via old http://www.URLs.com/pages.html anymore. I'm not sure, I think you should restart Apache, or you can restart it all with the same effect, while there can be some caching system that prevents you to see any change.
You can connect. Grow your network, collaborate, and get one new follower : ))
https://www.linkedin.com/in/jurajvysvader
https://twitter.com/Unisoftdev1


Locked

Return to “Search Engine Optimization (Joomla! SEO) in Joomla! 3.x”