Forum Moderators: phranque
I am new in redirect.htaccess and cannot understand much commands of it.
what I need is rewrite command for example.com/data?url=www.google.com to example.com/google.com
I know its pretty simple for you guys but I couldnt find a solution using my knowledge.
please help me to resolve the same.
thank you all
Mathew
and I am able to redirect
like this
Options +FollowSymLinks
RewriteEngine on
RewriteRule url/(.*) links.php?domain=$1 [L]
I am able to get result by typing example.com/url/google.com using above command. but when i access through example.com/data?url=google.com the browser url is not changing to example.com/google.com.
like compete.com or quantcast.com
any help?
THanks
Mathew
This new rule will also need to check to be sure that it is a client requesting the "links.php" path, and that the path is not being requested as a result of your first rule above. If this check is not done, then the result will be an infinite rewrite/redirect loop.
I've made the code a bit more robust, as you've got some potential here for malicious abuse.
Options +FollowSymLinks
RewriteEngine on
#
# Externally redirect (only) direct client requests for links.php?domain=<domain> to /url/<domain>
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /links\.php\?domain=http://(www\.)?([^/\ ]+)[^\ ]*\ HTTP/
RewriteRule ^links\.php$ http://www.example.com/url/%2? [R=301,L]
#
# Internally rewrite "url/" requests to exit-link-tracking script if referer is my site (or blank)
RewriteCond %{HTTP_REFERER} ^((www\.)?example\.com.*)?$
RewriteRule ^url/(.*)$ links.php?domain=$1 [L]
Jim
[edited by: jdMorgan at 1:28 am (utc) on Nov. 23, 2009]
If you get server errors, check your server error log -- some good information in there, usually.
Jim
I lost three four days to find a solution for my requirement..I was able to do all other redirections using examples provided in this forum and other websites but for this case not.
I have invested 5-6 months for my upcoming site whcih is launching shortly.
this is a free site offering Pageviews,page visits,visitors,unique visitors,average stay,pages per visit,site details,backlinks,domain info,server info etc.
so I dont have enough time to spend for redirection. this is the reason why I requested the complete code.
one more question if I need to avoide "url" directory then how this will work I have removed "url/" from above code but it doesnt update sites as it shows only first domain info...
Thanks again
Mathew
Please re-state your exact requirements, with correct example URLs and filetpaths. I don't know, for example, where "data?url=" came from -- It just sort of appeared in the discussion. I also don't know what you mean by "avoid 'url' directory."
These things usually go much easier if you state the specific URL-path requested by the browser and a specific disposition for that request; Either it should be re-written to a specific server filepath, or it should be redirected to a different specific URL. We need all the details, and solid, consistent examples.
Jim
If you don't put *some* kind of prefix on the exit-tracking URLs, then a request for /robots.txt will be exit-tracked and redirected to http://www.robots.txt/ -- Every file on your site will become an "exit URL" and your site will cease to function.
Jim
BUt tel me then how [other DNS information sites like compete.com or quantcast.com] works?
if you type <dns-chscker-site>.com/google.com then it works well and get results what you search for.
This is the same way which I also looking...when some one search my site www.example.com/google.com then he should get result. in short instead of www.example.com/url/google.com to www.example.com/google.com....
Best
Mathew
[edited by: jdMorgan at 5:07 pm (utc) on Nov. 28, 2009]
[edit reason] example.com [/edit]
Another way to do it is to 'filter' based on all known filetypes on your site. That is, don't rewrite to the script if there is no filetype, or if the filetype is .html, .php, .jpg, .gif, .png, .ico, .css, .js, .mp3, .avi, etc., etc. -- But you need a *complete* list. All other period-delimited strings at the end of requested URL-paths will then be assumed to be domain TLDs, and will be rewritten to your script.
You'll have to research this and determine the best way for your site, considering the complexity of the exclusion and ease of long-term maintenance.
Jim
I have another problem...actually i was busy on final touch on my new site launch..everything was complete and when I use forms to submit then I am getting 404 error.but if you enter in browser it works fine..what may be the problem?
here is my form
<form name="backlinkform" action="links.php" method="get">
<label>Domain Name
<input name="domain" type="text" value="" size="45" width="300px" height="20px">
</label>
<label>
<input type="submit" value="Submit" id="submit" >
</label>
</form>
now i am facing problem with css. css files are'nt loading! if you check the path it shows /url/style.css but there isnt any directory called url.
what may be the reason? why I need to remove "RewriteCond %{HTTP_REFERER} ^((www\.)?example\.com.*)?$"
Mathew
Jim