turbopowerdmaxsteel 0 Report post Posted March 15, 2008 I have a Buy Now page for one of my existing softwares located at http://forums.xisto.com/no_longer_exists/. The page is generated based on a query from the database which includes product name/price. One of my products will now support different versions which will vary in costs. I want to redirect the visitor to an internal page like http://forums.xisto.com/no_longer_exists/ when they visit the former link. But, I want the URL displayed on the Browser to be http://forums.xisto.com/no_longer_exists/. I know this is called internal redirect and can be done through mod_rewrite, but I am at a loss on how to do it. Please help. Share this post Link to post Share on other sites
tansqrx 0 Report post Posted March 17, 2008 I had a very similar problem a few weeks ago but never found a good answer. I have a new version of YCC Bot Maker that went from version 1.1 to 1.2. I usually publish my software with the Association of Shareware Professionals via a PAD file (http://pad.asp-software.org/). Long story short they have a repository that any shareware or software publisher can access and put your software on their site. Some of the sites that pick up the software a pretty cheesy but it sure drives a lot of traffic.By reviewing my logs I found out that more people are downloading the older non-working version than the newest one. This of course makes me look bad as a software developer so I investigated. It turns out that many of the download sites never go back and update their records for updates even though ASP provides this function. They apparently do a mass fetch from the database and never do any updating.The perfect solution would be a redirect. When accessing Cpanel you can access redirects via Site Management Tools > Manage Redirects. You can put in the old path that you don’t want to show anymore and more them to either another domain or somewhere else on your site. The interface is fairly straight forward but you have to remember add the domain name to the second field if you want to stay within you own site.My problem is that I want to redirect a file that happens to be a .RAR. The user interface completely choked and kept adding an extra “/” at the end of the from string. I can only assume that it doesn’t recognize a RAR file and has this problem. I then manually edited the redirects file by opening “.htaccess” and changing RewriteRule to what it should be. I never did get it to work even after much Google hunting and trial and error.In the end I deleted the file and created a custom error page (Site Management Tools > Custom Error Pages). From reviewing the logs I knew that most of the errors came from the missing download so I added the usual 404 error message and added links to the main sections. At the bottom I also said if you are looking for YCC Bot Maker then you can access it directly here. I don’t believe this is the best method and I would like to have a redirect but I just couldn’t get it to work. Share this post Link to post Share on other sites
turbopowerdmaxsteel 0 Report post Posted March 17, 2008 I have managed to get the ModRewrite working. Suppose your old RAR file is located at http://forums.xisto.com/no_longer_exists/ and the new file is located at http://forums.xisto.com/no_longer_exists/. Create the .htaccess file in the downloads directory with the following code:- RewriteEngine OnRewriteCond %{THE_REQUEST} yccbotmaker1\.1\.rar [NC]RewriteRule .* /downloads/yccbotmaker1.2.rar [L] My problem was that the page I was re-directing from had a query string at (http://forums.xisto.com/no_longer_exists/) and the REQUEST_URI server variable would only contain upto /products/buy/[/b[, so the regular expressions never matched. After some googling, I found out that THE_REQUEST server variable contains the exact file path specified in the HTTP request by the browser. Share this post Link to post Share on other sites
tansqrx 0 Report post Posted March 17, 2008 I will look at doing this but regular expressions never were my friend. What does the [NC] and [L] mean? Share this post Link to post Share on other sites
turbopowerdmaxsteel 0 Report post Posted March 18, 2008 NC stands for no-case which means the regular expression will not be case-sensitive. L stands for last-rule which implies that re-writing should stop here and no more rules should be applied. Share this post Link to post Share on other sites
tansqrx 0 Report post Posted June 10, 2008 I drummed up enough courage to try the redirects but it didnât end like I expected. When browsing to the file to be redirected (or any file in the directory) I got an internal server error. Here is what I had:RewriteEngine OnRewriteCond %{THE_REQUEST} YCC Bot Maker 1.2.rar [NC]RewriteRule .* /Files/YCC Yahoo Bot Maker 2.0.zip [L]I would like to redirect any request to http://forums.xisto.com/no_longer_exists/ Bot Maker 1.2.rar to http://forums.xisto.com/no_longer_exists/ Yahoo Bot Maker 2.0.zip I had the .htaccess file located in http://forums.xisto.com/no_longer_exists/. I hate to out right ask for a solution but like I said before I am having problems. Share this post Link to post Share on other sites
turbopowerdmaxsteel 0 Report post Posted June 10, 2008 In the RewriteCond line, . is a pattern matcher, you need to escape it with \RewriteEngine OnRewriteCond %{THE_REQUEST} YCC Bot Maker 1\.2\.rar [NC]RewriteRule .* /Files/YCC Yahoo Bot Maker 2.0.zip [L]Hope this helps. Share this post Link to post Share on other sites
tansqrx 0 Report post Posted July 3, 2008 I still donât know whatâs Iâm doing wrong. I placed the following .htaccess file in the Files directory and I get the following message Internal Server ErrorThe server encountered an internal error or misconfiguration and was unable to complete your request.Please contact the server administrator, webmaster@ycoderscookbook.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.More information about this error may be available in the server error log.Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. --------------------------------------------------------------------------------Apache/1.3.41 Server at ycoderscookbook.com Port 80The contents of the .htaccess file areRewriteEngine OnRewriteCond %{THE_REQUEST} YCC Bot Maker 1\.2\.rar [NC]RewriteRule .* /Files/YCC Yahoo Bot Maker 2.0.zip [L] Should I be adding this to the .htaccess file in the root directory instead of the subdirectory? Share this post Link to post Share on other sites
turbopowerdmaxsteel 0 Report post Posted July 3, 2008 The problem is with the spaces in the filename. I have done some testing and come up with this:- RewriteEngine OnRewriteRule YCC(.*)Bot(.*)Maker(.*)1\.2\.rar$ /Files/YCC$1Yahoo$1Bot$1Maker$12.0.zip [R] I couldn't find any other way to include the whitespace in the RewriteRule substitue parameter (/Files/YCC$1Yahoo$1Bot$1Maker$12.0.zip). So, I memorized the space using the (.*) in the expression and substituted the space using $1. Let the .htaccess file be in the Files subdirectory. Share this post Link to post Share on other sites
iGuest 3 Report post Posted August 3, 2008 Hello,do you mean you want to rederect a internal page to another internal page?can you give me abit more infomationCheersJay Share this post Link to post Share on other sites
tansqrx 0 Report post Posted August 12, 2008 Well here is the back story. From ycoderscookbook.com I publish several freeware programs for Yahoo! Messenger. Because my programs are very dependant on the Yahoo! servers, anytime they change something on their backend I have to make an update and republish the new binary. In order to get the word out more about my programs I also routinely publish on shareware and freeware sites via a PAD file (http://pad.asp-software.org/). The problem is that many of the third-party software sites are sometimes not very quick to update their databases. They will snap up your program in a matter of days but they will never update the listing after that even if you ask. The PAD system allows the publisher to remove or update any software but most of the sites that pick up software are just huge ad farms and they donât care what happens to a program once it has been added to the system. To this day I get download requests for software that has gone through five revisions and is 3 years out of date. When you get just as many requests for outdated software as current software then it can really hurt your image.Here is a real world example that I just pulled off of my logs (sadly it was the first entry). The first entry is outdated and the second is the current.⢠http://forums.xisto.com/no_longer_exists/ Bot Maker 1.1.rar⢠http://forums.xisto.com/no_longer_exists/ Yahoo Bot Maker 2.0.zipTo prevent the first file from getting a 404 message I would like to internally redirect the first file to the second file Share this post Link to post Share on other sites
turbopowerdmaxsteel 0 Report post Posted August 13, 2008 I have also faced this problem of users having to try one of the outdated version of my softwares. My solution to this is to have an auto updater bundled along with all my applications. You could use one of the third party update managers or build one yourself.Did you try the last code I posted? It should work. Also, if I may suggest, you could use a simple technique of not including the version number in the filenames. A user can easily check out the version stored in the file's metadata. That way, you wouldn't have to rely on redirects. Share this post Link to post Share on other sites
tansqrx 0 Report post Posted August 13, 2008 I do have a small update feature that checks to see if you are running the latest version of YCC Yahoo Bot Maker. I have tried the auto updating feature in the past but it turned nasty really quick because you have to have a second program to do the actual updating. I also thought of having the same name for all the executables and removing the versioning but I like to keep the versions separate and it will not solve the current issue because all of the problem sites are still referencing the file name with the outdated version.I also quickly tried the suggestion above and unfortunately it did not work. It still gave the same 500 Internal Error message. I didn’t fool with it very much because I wasn’t on my main machine at the time. Share this post Link to post Share on other sites
turbopowerdmaxsteel 0 Report post Posted August 14, 2008 It works on my end. Check out YCC Bot Maker 1.2.rar. The .htaccess file is contained within the Files directory. You might have some other rewrite rules in your .htaccess file that is causing the 500 Internal error to be shown. Try using a .htaccess file with just the following code:- RewriteEngine OnRewriteRule YCC(.*)Bot(.*)Maker(.*)1\.2\.rar$ /Files/YCC$1Yahoo$1Bot$1Maker$12.0.zip [R] Share this post Link to post Share on other sites
tansqrx 0 Report post Posted February 9, 2009 I finally found a solution to the redirect problem. Htaccess is funny because you cannot have spaces in the file to redirect from but you can in the file to redirect to. You also can have periods in the file to redirect from but not in the file to redirect to. To get around this you can use â\sâ to replace the spaces and â\.â to replace the periods. To reiterate my problem, I need to redirect http://forums.xisto.com/no_longer_exists/YCC Bot Maker 1.1.rar to http://forums.xisto.com/no_longer_exists/ YCC Yahoo Bot Maker 2.2.0.zi ycoderscookbook.com/files/ YCMaker 2.2.0.zip and the code to do that is: #YCC Bot Maker 1.1.rarRewriteCond %{HTTP_HOST} ^ycoderscookbook.com$ [OR]RewriteCond %{HTTP_HOST} ^ycoderscookbook.com ^Files/YCC\sBot\sMaker\s1.1.rar$ "http\:\/\/ycoderscookbook\.com\/files\/YCC Yahoo Bot Maker 2\.2\.0\.zip" [R=301,NC,L] As I stated before, you will notice the spaces were taken out of the first part and the periods taken out of the second part. Additionally I have several other redirects to take care of other versions. #YCC Bot Maker 1.2.rarRewriteCond %{HTTP_HOST} ^ycoderscookbook.com$ [OR]RewriteCond %{HTTP_HOST} ^ycoderscookbook.com ^Files/YCC\sBot\sMaker\s1.2.rar$ "http\:\/\/ycoderscookbook\.com\/files\/YCC Yahoo Bot Maker 2\.2\.0\.zip" [R=301,NC,L]#YCC Yahoo Bot Maker 2.0.zipRewriteCond %{HTTP_HOST} ^ycoderscookbook.com$ [OR]RewriteCond %{HTTP_HOST} ^ycoderscookbook.com ^Files/YCC\sYahoo\sBot\sMaker\s2.0.zip$ "http\:\/\/ycoderscookbook\.com\/files\/YCC Yahoo Bot Maker 2\.2\.0\.zip" [R=301,NC,L]#YCC_Yahoo_Bot_Maker_2.0.zipRewriteCond %{HTTP_HOST} ^ycoderscookbook.com$ [OR]RewriteCond %{HTTP_HOST} ^ycoderscookbook.com ^Files/YCC_Yahoo_Bot_Maker_2.0.zip$ "http\:\/\/ycoderscookbook\.com\/files\/YCC Yahoo Bot Maker 2\.2\.0\.zip" [R=301,NC,L]#YCC Yahoo Bot Maker 2.0.1.zipRewriteCond %{HTTP_HOST} ^ycoderscookbook.com$ [OR]RewriteCond %{HTTP_HOST} ^ycoderscookbook.com ^Files/YCC\sYahoo\sBot\sMaker\s2.0.1.zip$ "http\:\/\/ycoderscookbook\.com\/files\/YCC Yahoo Bot Maker 2\.2\.0\.zip" [R=301,NC,L] If you donât get it just right then you will end up with an internal server error. Always make a backup of your original .htaccess file so if you do get an internal server error and canât find a way around it then you can upload the original and at least have a functioning web site. Share this post Link to post Share on other sites