Forum Moderators: phranque
I'm trying to do a permanent 301 redirect from one url to the other and because I'm using fp 2002 with fp extensions, my web host on apache says iI have to email them the script for them to put into the .htaccess file. I would prefer to do it myself, but i suppose I have no other choice?
Anyway, I'm not entirely sure of the correct code, I am fairly sure that the code below wouldn't be correct, but it would be handy as a starting point.
What do I need to change please?
Do I need to specify the url that its coming from?
Any help appreciated.
RewriteEngine ON
RewriteCond %{HTTP_REFERER} ^http://www.mysite.com/gallery.html.*$ [NC]
RewriteRule ^.*_001.jpg$ http://www.mysite.com/redirect.html [R,L]
[edited by: jdMorgan at 2:35 am (utc) on Jan. 8, 2004]
[edit reason] de-linked [/edit]
There are three problems:
The RewriteCond to prevent looping for your specific substitution - as given above - would be
RewriteCond {REQUEST_URI} !/redirect\.html$ However, that third problem is a killer, so I can't provide anything useful until that is resolved.
Jim
Here are some resources:
Introduction to mod_rewrite [webmasterworld.com]
Apache mod_rewrite documentation [httpd.apache.org]
Apache URL Rewriting Guide [httpd.apache.org]
Using Regular Expressions [etext.lib.virginia.edu]
Topic Search on WebmasterWorld [google.com]
Jim
I did actually look at the info you suggested, but to my non-tech brain, it seems a bit tricky to grasp.
There's 3 domain names, forexample1.com, forexample2.com and forexample3.com, but only 1 website.
forexample1.com has a good pr and forexample3.com is the one that I would like anyone to be riderected to, from ANY pages in either forexample1.com or either forexample2.com
Do I need to specify anywhere, any of the details of the domain names that are being redirected FROM?
I have to send the code to my web host for them to do. They use Apache and mod_rewrite.
Here's the sample code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^forexample.com$
RewriteRule ^(.+) http://www.forexample.com/$1 [L,R=301]
Can anyone please let me know if this is correct please?
Dougie.
[edited by: jdMorgan at 2:35 am (utc) on Jan. 8, 2004]
[edit reason] de-linked [/edit]
Many, many thanks for this Jim.
One thing, after stacks of hours searching these archives, I seem to remember one the threads that you were involved in, saying that spaces are a bit of a prob on this board?
is the code above *exactly* how it should be, ie are the spaces ok, bearing in mind the prob with the spaces here?
Also, is there a limit to how many domain names you can redirect FROM, could you put 10 for example?
Your help is very much appreciated.
Dougie.