Search page in subdirectory with extra parameter in friendly URL (htaccess)

My htaccess is currently

# rewrite engine on and setting up base RewriteEngine On RewriteBase /leffa # replace + with _ RewriteRule ^(.+)\+(.+)$ $1-$2 [R=301] # external redirect from action URL to pretty one RewriteCond %{THE_REQUEST} /index(?:\.php)?\?q=([^\s&]+) [NC] RewriteRule ^ %1? [R=302,L,NE] # internal forward from pretty URL to actual URL RewriteRule ^([^/.]+)/?$ index.php?q=$1 [L,QSA,NC]

Which produces correct rewrite in here when you click on any of the movie titles. However, I have an extra parameter ?kuvauksesta=1 when you are searching from description also rather than the title (I have removed the checkbox because it currently doesn't work).

How to make this rewrite work with second parameter in search query? typing manually http://www.rollemaa.org/leffa/pelottava?kuvauksesta=1 does work, but with checkbox input it just removes the second parameter, try and see: http://www.rollemaa.org//leffa/index.php?q=pelottava&kuvauksesta=1

How to make the second parameter to say in the url so it's clean and searchable?

--------------Solutions-------------

Have it this way:

# rewrite engine on and setting up base
RewriteEngine On
RewriteBase /leffa/

# replace + with _
RewriteRule ^(.+?)\+(.+)$ $1-$2 [R=301,L,NE]

# external redirect from action URL to pretty one
RewriteCond %{THE_REQUEST} /index(?:\.php)?\?q=([^\s&]+)&(kuvauksesta)= [NC]
RewriteRule ^ %1/%2? [R=302,L,NE]

RewriteCond %{THE_REQUEST} /index(?:\.php)?\?q=([^\s&]+)\s [NC]
RewriteRule ^ %1? [R=302,L,NE]

# skip all files and directories from rewrite rules below
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

# internal forward from pretty URL to actual URL (extra parameter)
RewriteRule ^([^/.]+)/([^/.]+)?$ index.php?q=$1&$2=1 [L,QSA]

# internal forward from pretty URL to actual URL
RewriteRule ^(.+)/?$ index.php?q=$1 [L,QSA]

Category:php Time:2017-11-30 Views:2

Related post

Copyright (C) pcaskme.com, All Rights Reserved.

processed in 0.592 (s). 13 q(s)