|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
Using .htaccess file to redirect user to webpage
Hi, I would like to know what code to use in htaccess file in order to redirect a user who types in say www.mycompany.com/fundraising and then instantly directs them to a webpage that actually exists like http://www.mycompany.com/somethings...s/lastthing.htm. This is so the user does not have to type that long string in order to get to the view the page. This is used alot by companies to promote special offers etc.
Would it be on the lines of: RedirectMatch ^/fundraising http://www.mycompany.com/somethings...s/lastthing.htm in the htaccess file, but where? does it matter? I have used a meta refresh for that purpose, like this; <META HTTP-EQUIV="Refresh" CONTENT="0;URL=http://www.mycompany.com/somethings/someotherthings/lastthing.htm"> <META NAME="GENERATOR" CONTENT="Mozilla/3.0Gold (Win95; I) [Netscape]"> and I have just called it a name without the extension name like 'fundraising' However, it's very slow and the user knows they are being redirected. I need something a bit more smooth and professional. |
|
#2
|
|||
|
|||
|
simple like this
redirect /example/ http://www.mycompany.com/fundraising.html nto hard at all . as soon as the example link is parsed, it then looks at the htaccess file, and redirects the link to the fundraising.html file.try it out, and see if this helps you solve your problem. ![]()
__________________
Apache Expert |
|
#3
|
||||
|
||||
|
Quote:
Thanks asp! What appeared to be as simple as copying a file in DOS, turned out to be the most frustrating and puzzling time I have ever had! Can I just point out that I was trying redirect to url FROM /fundraising TO a complicated path but I could see your point. My website is hosted on a shared server by 1&1. They have FAQ which has examples of code that actually encourages you change your .htaccess file in order to manipulate the url. At first I used the RewriteEngine On RewriteRule ^test.html /test.php and uploaded to my website using dreamweaver (which has built the whole site) as a simple test to see if I was able to make changes to the .htaccess that worked, here I created 2 files so typing in /test.html would redirect to /test.php. After a while convinced that it was the server, I called 1&1 who edited my .htaccess file for me to exclude this line of code:- IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti* and then suddenly it worked in my IE browser. Fine, I could go ahead and make changes myself knowing that this syntax was good. No! whatever I did not not make any difference, and in fact deleting the file made no difference on my IE browser! I then used Safari and the redirect did not work, nor did it work on any other machine I have on any type of browser. Restoring the original working file did change anything either, only the original IE browser (even after restarting) kept being faithfully re-directing the test. I called them again and a different person suggested that changes made to that file could take hours to take affect. The next morning, no change, called 1&1, convinced him that something weired going on, he created a new .htaccess himself, inserted my code and it worked! I asked him to change it to what I really wanted which was if /fundraising was added to the end of my domain name it would redirect to it to a unfriendly path, he used that and it did not seem to would and we put it down to that a file called fundraising needs to exist, even though I think it should not care. In the end, he put his own code in using another command (which is not too dissimilar to yours) as follows:- redirect permanent /fundraising http://mydomain.co.uk/0cashbackshops/CashbackshopsIF.php and it works. it appears that RewriteEngine On RewriteRule ^fundraising /0cashbackshops/CashbackshopsIF.php [R] does not work So it appears that I have had multiple problems that compounded the resolution, that worst of all not being able to make changes myself even though they do get uploaded (I know this because the 1&1 staff have used the code). A browser with a memory which displays historical events. Even though it works now I am still confused as to why I should get so many problems, could you please suggest anything I could do to help me? |
|
#4
|
|||
|
|||
|
ok explain to me exactly what the issue is, so i can better assist you. i read your response but i would like to know, what all do you have in your .htaccess file? if you could post an example of the stuff you have in your htaccess file.
also are the you trying to redirect this from a server not on your main host? ![]() |
|
#5
|
||||
|
||||
|
Hi asp! The issue after my long explaination is that it now works and does what it's meant to, but I have to get 1&1 to edit the file for me. For that reason, it's not really an issue about what goes in the file but how the file is edited.
|
|
#6
|
|||
|
|||
|
hmmm you can't ftp to your main directory under ascii? i mean i think that's a bit much, when you can't edit the file yourself, cause that's a lot of time wasted waiting on them to fix the setting for you.
|
|
#7
|
||||
|
||||
|
I know it's been a while but it's one of things I put on the back burner! ....and recently after discussing issues on other topics, I suspect it could be the fault of my dreamweaver text editor not giving me the truth such as text editors do. Therefore I'm ftp'in up garbage and as far as I'm aware it's good. I have a case about 2 years ago, where I cut and pasted a whole bunch of php code into dreamweaver's editor and it wouldn't work. Explaining my problem of this forum I pasted the code onto this box and submitted the post. Upon viewing the post after submitting, the php code between the code tags it showed up all sorts of erroneous characters not seen in the dreamweaver text editor.
Therefore a good text editor and a separate ftp client should sort things out. |
![]() |
| Viewing: Dev Articles Community Forums > Web Design > Web Server Configuration > Using .htaccess file to redirect user to webpage |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|