Jump to content
xisto Community
dazedandconfused1405241578

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

Recommended Posts

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!

Share this post


Link to post
Share on other sites

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

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...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.