Nov 21, 2009

Htaccess Reditrect Help - Trying to redirect a directory of html files to php files

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > Programming > Programming General > Design Practises, Patterns & Ideas

Htaccess Reditrect Help - Trying to redirect a directory of html files to php files

dazedandconfused
Hey guys-

New to the forum and have a question you'll probably think is really easy with htaccess.

I've recently completed 1 phase of a redesign of a website and have changed files in a directory from html to php. I know I can use the 302 redirect for making the permanennt change, but I was trying to avoid targeting each file and would rather target the complete directory.

Here's an example of what I need to do:

http://mydomain.com/main/*anyfile.html redirects to http://mydomain.com/main/*anyfile.php

Any help would be greatly appreciated!

Thanks!

Comment/Reply (w/o sign-up)

wutske
Imho that's not a good way, either link to the correct files or don't link to them at all.

Comment/Reply (w/o sign-up)

yordan
If you are on a Linux system, you can do a little bit scripting in order to do the job.
Once you have the names of the files you renamed (for instance names.html should become names.php)
You can obtain the list of the concerned files with something like "grep names.php *"
And then, for each of the concerned files, do
CODE
cat $1 |sed 's /names.html/names.php/g'|sed 's/file2.html/file2.php' >$1.tmp; cp $1.tmp $1

Of course, backup your source folder, and first test it without the last "cp" instruction...

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)


See Also,

*SIMILAR VIDEOS*
Searching Video's for Htaccess, Reditrect, Help
Similar
.htaccess
advertisement



Htaccess Reditrect Help - Trying to redirect a directory of html files to php files

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com