Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- htaccess wrong code ?


sublime1 - 3:12 pm on Nov 15, 2010 (gmt 0)


Noximus --

The first parameter of the RewriteRule contains only the path info, not the fully qualified domain name.

If your RewriteRule is in the server configuration or a VirtualHost configuration, then the path will start with a /. If it is in a .htaccess file (more common, less desirable if you have the choice between the two) then the path will not start with the /. In the latter case, you'll also have to set RewriteBase.

Here's code for a server-base/virtual host context:


Options +FollowSymLinks -MultiViews
RewriteEngine on

RewriteRule ^/folio.html$ http://www.sample.com/Showcase.htm [R=301,L]
RewriteRule ^/Residential.html$ http://www.sample.com/Stones.htm [R=301,L]


In a .htaccess context it would be



Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /

RewriteRule ^folio.html$ http://www.sample.com/Showcase.htm [R=301,L]
RewriteRule ^Residential.html$ http://www.sample.com/Stones.htm [R=301,L]



The ^ means "starts with" -- a good practice to get into (you might, for example have a "Portfolio.html" page, which would also match :-). $ means "ends with".

Tom


Thread source:: http://www.webmasterworld.com/apache/4230525.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com