Using htaccess I have these php rules:
<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
## don't touch /forum URIs
RewriteRule ^forums/ - [L,NC]
## hide .php extension snippet
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L]
# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]
# To remove www header
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [L,R=301]
</IfModule>
Everything is working, except if I do a search, the search results page is not showing the results because it is taking out the php extension. Example: search/?s=building where "building" is the term used. Generally, it should look like this: search.php?s=building
How do I tell htaccess that I only wanted to hide the php extensions of the pages except the results page?
search
orsearch.php
(it should be the former)..php
extension as well, otherwise all your navigation is going to result in an external redirect (2 requests) - which is what's happening.