1

I want to turn my search URLs into directory format, meaning I want to turn:

/search?q=hi

Into:

/search/hi

How can this be done with .htaccess? I already have this in my .htaccess to remove the .php from the pages:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

Thanks in advance.

Nathan
  • 11,814
  • 11
  • 50
  • 93

1 Answers1

1

This shoud do the trick (Remove your code for subtracting php extension):

RewriteEngine On 
RewriteBase /
RewriteRule ^search/(.+) /search.php?q=$1
RewriteCond %{QUERY_STRING} ^q=(.+)
Zeno Popovici
  • 589
  • 3
  • 15