Forum Moderators: phranque
All the best, Niklas
But bear in mind that basing your Rewrite upon the HTTP user-agent requires a lot of care; Many plugins do not send a unique HTTP User-agent string in their requests. Many users have "Internet Security" software that blocks the HTTP User-agent and the HTTP Referer headers -- and they may not even be aware of this. And users behind corporate or ISP caching proxies such as all AOL users, make their requests through those proxies, and the proxy will not pass every request to your server -- and if it does, then those HTTP headers may be missing or modified.
About all you can count on is that in most cases, the search engine spiders *will* provide a proper HTTP User-agent string, unless they are cloaking to check out your site as a human visitor would see it. But when dealing with human visitors, their browser plugins, their company or ISP proxies, and their security software, you really can't count on anything to be 100% reliable.
Be aware that in order to 'steer' requests to different files (or scripts), an external HTTP redirect is not needed. Nor is it recommended. Instead, a server-internal rewrite should be used. The same is true for this "plugin" you're using: It should not be making HTTP requests for files on the server when it could simply access the files in the local filesystem directly. Look and see if there is a configuration option for this; If all files that it needs are local, there is no reason to use HTTP requests to get them -- It's hundreds to thousands of times slower.
Jim
Thanks for getting back to me so fast!
Well - some of the things your talking about seems to be a little over my head but extremely interesting! :)
All the redirects are handlng files that are located on the same server. How do I make and use "server-internal rewrites"?
Here is the .htaccess file that I have so far (it could probably be written in a better format - I'm just not hundred percent sure just yet of what I'm doing here since .htacess is new to me):
# Enables mod_rewrite
RewriteEngine on
# Sets the base folder
RewriteBase /
#Redirects only when visiting with browsers
RewriteCond %{HTTP_USER_AGENT} !Googlebot¦Msnbot¦Slurp¦Jeeves [NC]
# Redirects
RewriteRule ^home\.html$ index.html [R,NE,L]
#Redirects only when visiting with browsers
RewriteCond %{HTTP_USER_AGENT} !Googlebot¦Msnbot¦Slurp¦Jeeves [NC]
RewriteRule ^home_en\.html$ index_en.html [R,NE,L]
#Redirects only when visiting with browsers
RewriteCond %{HTTP_USER_AGENT} !Googlebot¦Msnbot¦Slurp¦Jeeves [NC]
RewriteRule ^jobb_webb\.php$ #/portfolio [R,NE,L]
#Redirects only when visiting with browsers
RewriteCond %{HTTP_USER_AGENT} !Googlebot¦Msnbot¦Slurp¦Jeeves [NC]
RewriteRule ^jobb_tryck\.php$ #/portfolio [R,NE,L]
#Redirects only when visiting with browsers
RewriteCond %{HTTP_USER_AGENT} !Googlebot¦Msnbot¦Slurp¦Jeeves [NC]
RewriteRule ^jobb_diverse\.php$ #/portfolio[R,NE,L]
#Redirects only when visiting with browsers
RewriteCond %{HTTP_USER_AGENT} !Googlebot¦Msnbot¦Slurp¦Jeeves [NC]
RewriteRule ^portfolio_web\.php$ index_en.html#/portfolio[R,NE,L]
#Redirects only when visiting with browsers
RewriteCond %{HTTP_USER_AGENT} !Googlebot¦Msnbot¦Slurp¦Jeeves [NC]
RewriteRule ^portfolio_print\.php$ index_en.html#/portfolio[R,NE,L]
#Redirects only when visiting with browsers
RewriteCond %{HTTP_USER_AGENT} !Googlebot¦Msnbot¦Slurp¦Jeeves [NC]
RewriteRule ^portfolio_misc\.php$ index_en.html#/portfolio[R,NE,L]
#Redirects only when visiting with browsers
RewriteCond %{HTTP_USER_AGENT} !Googlebot¦Msnbot¦Slurp¦Jeeves [NC]
RewriteRule ^om_mig\.html$ #/om%20mig[R,NE,L]
#Redirects only when visiting with browsers
RewriteCond %{HTTP_USER_AGENT} !Googlebot¦Msnbot¦Slurp¦Jeeves [NC]
RewriteRule ^about\.html$ index_en.html#/about%20me[R,NE,L]
#Redirects only when visiting with browsers
RewriteCond %{HTTP_USER_AGENT} !Googlebot¦Msnbot¦Slurp¦Jeeves [NC]
RewriteRule ^service\.html$ #/service[R,NE,L]
#Redirects only when visiting with browsers
RewriteCond %{HTTP_USER_AGENT} !Googlebot¦Msnbot¦Slurp¦Jeeves [NC]
RewriteRule ^service_en\.html$ index_en.html#/services[R,NE,L]
Because you are using "named anchors" (URLs containing "#anchor") you will have to use a redirect.
All I can do is give you a way to avoid the blank user-agent problem and to shorten your code at the same time:
# Enable mod_rewrite
RewriteEngine on
#
# Set the base folder
RewriteBase /
#
# Skip all subsequent rules if major search engine robot or if blank user-agent
RewriteCond %{HTTP_USER_AGENT} Googlebot¦Msnbot¦Slurp¦Teoma¦^$ [NC]
RewriteRule .* - [L]
#
# Redirects
RewriteRule ^home\.html$ index.html [R,L]
RewriteRule ^home_en\.html$ index_en.html [R,L]
RewriteRule ^jobb_webb\.php$ #/portfolio [R,NE,L]
RewriteRule ^jobb_tryck\.php$ #/portfolio [R,NE,L]
RewriteRule ^jobb_diverse\.php$ #/portfolio[R,NE,L]
RewriteRule ^portfolio_web\.php$ index_en.html#/portfolio [R,NE,L]
RewriteRule ^portfolio_print\.php$ index_en.html#/portfolio [R,NE,L]
RewriteRule ^portfolio_misc\.php$ index_en.html#/portfolio [R,NE,L]
RewriteRule ^om_mig\.html$ #/om%20mig [R,NE,L]
RewriteRule ^about\.html$ index_en.html#/about%20me [R,NE,L]
RewriteRule ^service\.html$ #/service [R,NE,L]
RewriteRule ^service_en\.html$ index_en.html#/services [R,NE,L]
RewriteRule ^jobb_webb\.php$ [b]http://www.example.co.uk/[/b]#/portfolio [R,NE,L]
Jim
[edited by: jdMorgan at 3:03 am (utc) on May 6, 2007]
Niklas