0

I had add this form in homepage of my theme

     <form action="" method="GET">

        <label>NAME:</label>
        <input type="text" name="name" id="name" required/>
        <button>GET</button>

     </form>

<?php
  if (isset($_GET['name'])){
  $name = $_GET['name'];
  echo "hello".$name;}
?>

and here I am getting url at top is

example.com/?name=google

and i want custom url as

example.com/name/google

so what should i do to get custom URL by get method?

1 Answers1

0

This is a basic rewrite rule. Here's the output for your .htaccess:

RewriteEngine On 

RewriteRule ^name/([^/]*)$ /?name=$1 [L]

OR You might as well try a forced 301 SEO friendly redirection:

# 301 --- http://example.com/?name=google => http://example.com/name/google
RewriteCond %{QUERY_STRING} (^|&)name=google($|&)
RewriteRule ^$ /name/google? [L,R=301]
MrJack Mcfreder
  • 692
  • 1
  • 10
  • 21