Forum Moderators: phranque

Message Too Old, No Replies

301

Can't make it work for specific files.

         

robertito62

7:17 pm on Jun 7, 2004 (gmt 0)

10+ Year Member



I have been trying to move this page:

/index.html

to

/this-other-page.html

Both in same site and directory.

But when I use the following .htaccess file nothing happens:
-----------------------------
RewriteEngine on
RewriteBase /index.html
RewriteRule ^/index.html(.+) [mydomain.com...] [L,R=301]
-----------------------------

I am dropping the .htaccess right at the root of the domain.

I have searched for answers in other threads to no avail. Perhaps someone can help clarify what should I change. Thanks.

gergoe

7:47 pm on Jun 7, 2004 (gmt 0)

10+ Year Member



RewriteBase is used to specify the path part of the url being used in that specific directory, so you only need the / for RewriteBase.
Additionally the ^/index.html(.+) pattern will match urls starting with index.html AND only when there's something after the html, like index.htmlx.
Last comment; the $1 in the substitution text (second part of the RewriteRule) means, replace it with the first grouped expression from the last RewriteRule match. Since you don't have grouped expression (expression in brackets, like this) in the pattern, it does not have any use.
So I suggest you to change the rules as follows:

RewriteEngine on
RewriteBase /
RewriteRule ^index\.html?$ http://www.mydomain.com/this-other-page.html [L,R=301]

This will redirect any request for /index.html and /index.htm to [mydomain.com...] If there was any query parameter in the original request then it will be appended for the redirection also (that's the default behavior)

I suggest you to take a look in the mod_rewrite documentation [httpd.apache.org] for details on these comments. If you prefer examples instead of the general documentation then check out the URL Rewriting Guide, there's a link at the bottom of that page.

jcoronella

7:49 pm on Jun 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



[removed] Gergoe got it nailed.

robertito62

4:11 am on Jun 8, 2004 (gmt 0)

10+ Year Member



gergoe,
it worked exactly as I wanted. Thank you.