Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to change WordPress default search slug [easy method 2023]

There are several reasons why you want to change the default WordPress default slug URL. The most important reason could be excluding it from Google Adsense ad requests to avoid policy violations.

Google Adsense doesn’t allow users to exclude pages that are query parameters such as the WordPress Search slug ?s=.

So how to change the Default Search Slug URL in WordPress?

You can easily change the default search slug from ?s= to /search/ by adding the following code snippet to your htaccess file:

# Change WordPress search URL slug
RewriteCond %{QUERY_STRING} \\?s=([^&]+) [NC]
RewriteRule ^$ /search/%1/? [NC,R,L]

Update the robots.txt file to disallow the new slug from being crawled by adding the following to your robots.txt file via Yoast -> tools – edit files or from your file manager.

Disallow: /search/

And also, now you can ask Google Adsense to exclude search pages from being severed with ads:

Go to your Adsense account –> Ads –> Click on the edit icon next to your domain name –> this will open the auto ads page, now from the right sidebar, select exclude pages –> add the desired pages –> done.

Google Adsense exclusions
This will prevent Google Adsense from serving empty search pages with ads, protecting your site from violating Google Adsense policies.

The post How to change WordPress default search slug [easy method 2023] appeared first on Digital Boom.



This post first appeared on Digital Boom, please read the originial post: here

Share the post

How to change WordPress default search slug [easy method 2023]

×

Subscribe to Digital Boom

Get updates delivered right to your inbox!

Thank you for your subscription

×