Home » Htaccess Tools » Questions regarding htaccess » 301 Redirect of .php files to html under sub-folder
301 Redirect of .php files to html under sub-folder [message #931] Tue, 22 April 2008 11:15 Go to next message
shinerweb  is currently offline shinerweb
Messages: 2
Registered: April 2008
Location: UK
I have a series of old .php files that exist under a sub-folder

/public_html/folder1/folder2/folder3/file1.php
/public_html/folder1/folder2/file2.php
/public_html/folder1/file2.php


I want to be able to 301 redirect those files to their .html equivalent.

/public_html/folder1/folder2/folder3/file1.html
/public_html/folder1/folder2/file2.html
/public_html/folder1/file2.html


Now I was thinking along the lines of

RedirectMatch 301 (.*)\.php$ http://www.example.com$1.html


But that doesn't work.

I'd rather have a rule that I can place in my top-level .htaccess, rather than have multiple .htaccess file dotted around, so I'm looking for a decent regex that would do this.

I could place a .htaccess in /public_html/folder1/ that would only effect that and any subsequent sub-folders to make it simpler, but I'm open to any suggestions.

I can't just redirect ALL php files to their html equivalent on the whole server. (Because I have some php files that I don't want 301' redirected).

But I have one sub-folder under which ALL php files can be 301 redirected.

Any help much appreciated.

Regards

Chris


Re: 301 Redirect of .php files to html under sub-folder [message #932 is a reply to message #931 ] Tue, 22 April 2008 11:48 Go to previous message
shinerweb  is currently offline shinerweb
Messages: 2
Registered: April 2008
Location: UK
Why is that always after I make a post I get a blazing flash of inspiration and answer my own question about 2ms after hitting the post button.

The following works, if I place it in the sub-folder,

RewriteRule ^(.*)\.php$ /folder1/$1.html [R=301,L]


So although it's not my ideal solution (of creating an entry in my top-level .htaccess file, at least I have a working solution for my problem.

I guess I'll have to get my regex book out.

Chris
Previous Topic:URL Redirection For Main DNS Question...
Next Topic:Insert html content at the bottom of every page
Goto Forum:
  


Current Time: Fri May 16 17:21:51 CEST 2008

Powered by: FUDforum 2.7.7.
Copyright ©2001-2007 FUD Forum Bulletin Board Software