Sunday, January 23, 2011

.htaccess help required for apache server

I searching for a redirection code for my url:

what I want is when some one search in my site it should redirect

example: if some one search google.com on mysite

then in address line it should look like www.mydomain.com/google.com

can be in $_POST method or $_GET

how do I do that??

  • RewriteEngine On
    RewriteCond %{HTTP_REFERER} google\.com
    RewriteRule ^.*$ http://www.mydomain.com/google.com [R,L]
    

    in an .htaccess file might work, i have not tested it.

    you could try:

    RewriteCond %{THE_REQUEST} ^[A-Z]+\ /(.*)\/search\.php\?q=(www\.)?([^/\ ]+)[^\ ]*\ HTTP/
    RewriteRule ^.*$ http://www.mydomain.com/%1 [R,L]
    

    this link also has some other example 'smart' .htaccess rules: http://www.askapache.com/htaccess/http-https-rewriterule-redirect.html

    mathew : RewriteCond %{THE_REQUEST} ^[A-Z]+\ /search\.php\?q=(www\.)?([^/\ ]+)[^\ ]*\ HTTP/ this is for request of any kind of search domains..but what I dont know is how do I convert to http://www.mydomain.com/domain.com
    cpbills : added another potential answer
    mathew : nop it doesnt work
    cpbills : does it do /anything/ can you provide more information as to how it doesn't help? maybe enable logging for RewriteRules `RewriteLog file-path` and `RewriteLogLevel 9` http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html you also have to be willing to play with the regular expression in the `RewriteCond` to see if you can at least get it to trigger. i don't know where you got that pattern, so i have no idea if it should work or not, you provided it.
    From cpbills

0 comments:

Post a Comment