6363

htaccess redirect from specific urls on home page or on another page?

Question:

I read over 20 posts, and I did not find a solution, so in my case I want to redirect https://example.com/search/ in home page or on another page, but i don't want to redirect https://example.com/search/?q=query

Is this possible?

I hope to have a solution.

Thanks

Answer1:

You need to check at the beginning of you search script if the environment variable QUERY_STRING has an empty value.

For instance, in Perl:

if ($ENV{QUERY_STRING} eq '') { {print "Status: 307 Temporary Redirect\n"; print "Location: https://example.com/\n\n"; exit; }

Recommend

  • Dispose not working as expected in DirectorySearcher
  • Fluid video height
  • Weird LEFT OUTER JOIN on Includes eager loading of rails 3
  • Updating and removing unique join relationships in CakePHP
  • Receiver has no segue with identifier“***”
  • in batch how do i use taskkill properly
  • Installing Perl6 and Panda on Ubuntu 15.10. Problems with bootstrap.pl
  • Can my PDF ping my server when it is opened?
  • Clear activity stack before launching another activity
  • Mysql - How to search for 26 records that each begins with the letter of the alphabet?
  • Webgrid not refreshing after delete MVC
  • preg_replace Double Spaces to tab (\\t) at the beginning of a line
  • ActiveRecord query for a count of new users by day
  • Can you perform a UNION without a subquery in SQLAlchemy?
  • Android full screen on only one activity?
  • Refering to the class itself from within a class mehod in Objective C
  • PostgreSQL Query without WHERE only ORDER BY and LIMIT doesn't use index
  • Google Custom Search with transparent background
  • How to avoid particles glitching together in an elastic particle collision simulator?
  • Recording logins for password protected directories
  • formatting the colorbar ticklabels with SymLogNorm normalization in matplotlib
  • Insert into database using onclick function
  • Splitting given String into two variables - php
  • What is Eclipse's Declaration View used for?
  • Accessing IRQ description array within a module and displaying action names
  • Check if a string to interpolate provides expected placeholders
  • Can I make an Android app that runs a web view in Chrome 39?
  • htaccess rewriting URLs with multiple forward slashes
  • Display Images one by one with next and previous functionality
  • Web-crawler for facebook in python
  • Return words with double consecutive letters
  • A cron job substitute?
  • InvalidAuthenticityToken between subdomains when logging in with Rails app
  • SQL merge duplicate rows and join values that are different
  • LevelDB C iterator
  • How can I remove ASP.NET Designer.cs files?
  • python draw pie shapes with colour filled
  • Can't mass-assign protected attributes when import data from csv file
  • Is there any way to bind data to data.frame by some index?
  • How can i traverse a binary tree from right to left in java?