htaccess 301 redirect

When you need to redirect your page based on query string from URL, you can put below code in your .htaccess file !


RewriteEngine on
 RewriteCond %{REQUEST_URI}  ^/array\.php$
 RewriteCond %{QUERY_STRING} ^id=([0-9]*)&name=([a-z]*)$
 RewriteRule ^(.*)$ http://mywebsite.com/index.php? [R=302,L]

REQUEST_URI will return name of the executed file.
QUERY_STRING will return query string variables in URL.

After you add above code in htaccess , all array.php pages with query string id & name will redirect to http://mywebsite.com/index.php.

Advertisements

I like to hear from you about this !!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.