How to use $_get parameter to make seo friendly urls?

by cameron_walter , in category: SEO , 8 months ago

How to use $_get parameter to make seo friendly urls?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

1 answer


by susan , 8 months ago


To use the $_GET parameter to create SEO-friendly URLs, follow these steps:

  1. Enable the rewrite engine in your web server (e.g., Apache). This allows you to rewrite URLs and redirect them to a specific script or page.
  2. Create a .htaccess file in your website's root directory (if it doesn't already exist).
  3. Write the following rules in your .htaccess file to redirect all requests to a specific script (e.g., index.php), with the requested URL passed as a query parameter:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

  1. In your PHP script (e.g., index.php), retrieve the requested URL using the $_GET variable:
$url = $_GET['url'];

  1. Perform any necessary processing or redirection based on the captured URL. For example, you can parse the URL to extract parameters and query a database accordingly.
  2. Display the corresponding content based on the captured URL.

By implementing these steps, you can create SEO-friendly URLs that are more readable by both search engines and users. For example, instead of using a URL like, you can have, which is much more user-friendly and beneficial for SEO purposes.