how to redirect .php to non extension URL??

Need help installing Joomla! 3.x? For all Joomla! 3.x installation issues please use this forum.

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.
Post Reply
User avatar
Simsan Mallick
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 117
Joined: Sat Apr 16, 2011 9:58 am
Location: Dhaka, BD
Contact:

how to redirect .php to non extension URL??

Post by Simsan Mallick » Thu Mar 08, 2018 5:35 am

Hello,
i need to redirect all .php extension page to non extension pages (exampal: /contact.php to /contact)

I got this form stackoverflow, it's works but making problem for the index.php redirect, maybe need to remove some lines for the index.php redirect.

RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.php
RewriteRule ^/?(.*)\.php$ /$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^/?(.*)$ /$1.php [L]

Looking for help. Thank you

swapna_021
Joomla! Apprentice
Joomla! Apprentice
Posts: 7
Joined: Wed Mar 07, 2018 2:13 pm

Re: how to redirect .php to non extension URL??

Post by swapna_021 » Thu Mar 08, 2018 7:02 am

Frist you have to Select the file extensions you want to redirect the file types that you want to redirect to its file names without adding the extension, for example, if you choose: “html”then every html file on your domain will be redirected to its file name without adding the extension

User avatar
leolam
Joomla! Master
Joomla! Master
Posts: 19139
Joined: Mon Aug 29, 2005 10:17 am
Location: Netherlands/ UK/ S'pore/Jakarta/ North America
Contact:

Re: how to redirect .php to non extension URL??

Post by leolam » Thu Mar 08, 2018 3:42 pm

In Joomla you do not have any pages (but for index.php) that end with the .php extension (so we have no "contact.php) so wondering what your issue is?

Leo 8)
Joomla's #1 Professional Support Provider:
-> Joomla Professional Support: https://gws-desk.com -
-> Joomla Specialized Hosting Solutions: https://gws-host.com -
Member Joomla Bug Squad & Joomla CMS Release Team

User avatar
Simsan Mallick
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 117
Joined: Sat Apr 16, 2011 9:58 am
Location: Dhaka, BD
Contact:

Re: how to redirect .php to non extension URL??

Post by Simsan Mallick » Thu Mar 08, 2018 7:30 pm

leolam wrote:In Joomla you do not have any pages (but for index.php) that end with the .php extension (so we have no "contact.php) so wondering what your issue is?

Leo 8)
issues is my old site build with PHP .php extension and build new with joomla and now need to make all URL redirect.

User avatar
leolam
Joomla! Master
Joomla! Master
Posts: 19139
Joined: Mon Aug 29, 2005 10:17 am
Location: Netherlands/ UK/ S'pore/Jakarta/ North America
Contact:

Re: how to redirect .php to non extension URL??

Post by leolam » Fri Mar 09, 2018 2:05 am

Try to add this

#Redirect any file which does not exist to the index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php [R=301,L]

Leo 8)
Joomla's #1 Professional Support Provider:
-> Joomla Professional Support: https://gws-desk.com -
-> Joomla Specialized Hosting Solutions: https://gws-host.com -
Member Joomla Bug Squad & Joomla CMS Release Team

epixelsolutions
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Tue Apr 10, 2018 10:10 am

Re: how to redirect .php to non extension URL??

Post by epixelsolutions » Sat Apr 14, 2018 3:38 pm

Hello,

Can you try this

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php


Post Reply

Return to “Installation Joomla! 3.x”