James
James

Reputation: 4580

htaccess redirect url with dynamic values to homepage

I have some issues with Google indexing certain unwanted URLs on my site such as http://www.example.com/%22tel:333-444-1234, where the number part is dynamic. These pages do not exist, and I am hoping to remove these links from Google's index by using the rel="nofollow" tag. But meanwhile I would like to redirect all URLs containing the string "%22tel:" to a page on my site such as http://www.example.com/page1.html.

I am using Apache. How do I do this?

I tried these codes, it doesn't seem to work.

RewriteEngine on
RewriteCond %{REQUEST_URI} ^\%22tel:
RewriteRule ^(.*)$ http://www.example.com/page1.html/

RewriteRule ^(.*)\%22tel:(.*)$ http://www.example.com/page1.html [L,R=301]

Thanks!

Upvotes: 1

Views: 114

Answers (1)

Amit Verma
Amit Verma

Reputation: 41219

You can use the following rule

RewriteEngine on
RewriteCond %{THE_REQUEST} /%22tel [NC]
RewriteRule ^ /page-1.html [L,R]

Upvotes: 2

Related Questions