Forum Moderators: phranque
I need your wisdom guys.
I need 2 rules to redirect humans and spiders
something like this:
For users:
RedirectPermanent /crete/hotels/index.htm [mysite.com...]
For Robots-Spiders:
RewriteRule ^/crete/hotels/index.htm $http://www.mysite.com/crete/crete-hotels.htm [R=301,L]
Considerations:
1.Will the first rule work for both humans and spiders?
2.If not can these two rules above exist in the same file without any problems?
Thank you in advance!
You will have better results with controlling interactions between two different redirects if you use either mod_alias or mod_rewrite, and not both. If you use both, you cannot explicitly control the order of execution of the directives for the two different Apache modules. That is determined by the LoadModule list on Apache 1.x, and by Apache 2.x's module priority scheme.
Mod_alias is simpler, mod_rewrite is more powerful. For example, mod_alias redirects unconditionally, while mod_rewrite has the RewriteCond directive that allows you to redirect based on user-agent, requesting IP address, etc.
Jim
the problem here is that I need the first rule to redirect the user's browser window and the second rule to redirect robots. If i use only the first one and go to access page
[mysite.com...]
I am redirected automatically to
[mysite.com...]
But dont know if this is the same case for robots.
That is why i was wondring if I can use the second rule as well for the robots
If I use only the second rule
RewriteRule ^/crete/hotels/index.htm $http://www.mysite.com/crete/crete-hotels.htm [R=301,L]
and access [mysite.com...] my browser is not redirected and I get a page not found error.
It drives me crazy
Your mod_rewrite rule has a syntax error in it, but this may just be a typo from posting here. The "$" is misplaced. It should read:
RewriteRule ^/crete/hotels/index\.htm$ http://www.example.com/crete/crete-hotels.htm [R=301,L]
RewriteRule ^crete/hotels/index\.htm$ http://www.example.com/crete/crete-hotels.htm [R=301,L]
It's also possible that you don't have any other working mod_rewrite rules in this file, in which case you need to add some "setup" directives for mod_rewrite.
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^/crete/hotels/index\.htm$ http://www.example.com/crete/crete-hotels.htm [R=301,L]
If you have a problem such as a 404-Not Found or a 500-Server Error, then go to your raw server error log file and see what the problem is. The error log file will often tell you exactly what the problem is, or at least show you the server filesystem path that the URL was translated to. This is often very useful information, and prevents the frustrating process of having us "help fix your problem by guessing" here.
Jim