legobear154
legobear154

Reputation: 431

HTML Form and mod_rewrite

OK, I have been trying to figure this out for a while. I just recently figured out how to use apache's mod_rewrite rules. I have a search script set up on my website and it uses GET. I have a html form with the GET method. The problem is when I submit the form my url comes out like this: http://localhost/search/?search=name&term=user when it should be this: http://localhost/search/name/user

Is there a way to make the url like the second? I am using php.

Here is my htaccess file as well:

RewriteEngine on
RewriteRule ^member/?([^/\.]+)?/?$ member.php?page=$1 [L]
RewriteRule ^games/?([^/\.]+)?/([^/\.]+)?/?$ games.php?page=$1&p=$2 [L]
RewriteRule ^search/?([^/\.]+)?/([^/\.]+)?/?$ search.php?search=$1&term=$2 [L]
RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [L]

Thanks, Legobear154

Upvotes: 1

Views: 770

Answers (2)

Shiplu Mokaddim
Shiplu Mokaddim

Reputation: 57650

This has nothing to do with mod_rewrite. You need to use JavaScript.

Create an onsubmit event handler for your form. And in the javascript function modify the form URL according to the form data.

Upvotes: 2

Knowledge Craving
Knowledge Craving

Reputation: 7993

Please try the following:-

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^member/([^/]+)/ member.php?page=$1 [NC]
RewriteRule ^games/([^/]+)/([^/]+)/ games.php?page=$1&p=$2 [NC]
RewriteRule ^search/([^/]+)/([^/]+)/ /search.php?search=$1&term=$2 [NC]
RewriteRule ^([^/]+)/ index.php?page=$1 [NC]

Hope it helps.

Upvotes: 0

Related Questions