I hope you can help me out with a little something...
Here's my situation and what I need to accomplish.
I have an html site. There ia a main structure as with most websites -- where index.html files exists in directories (e.g. /index.html /contact/index.html /news/index.html /links/index.html et cetera).
For those main pages, I have created better pages with php extensions.
Now, there are hundreds of other *.html files (those that do not begin with 'index' - they are not main dir files). These, as well as the main files, are well-indexed in the search engines.
I do not want to jeopardize the rank in the search engines, as much as possible (though not quite controllable, I understand...).
So, my idea was to redirect the index.html files from the main structure directories to the new index.php files in those same main directories.
The other html files would remain html files, though I would edit some of them to change links within them to point to the new index.php files, rather than the old index.html files (because these files will never be converted to or replaced by php files).
[Oh, and I would also go into the server's httpd.conf file and make sure that index.php is called first (for DirectoryIndex), then index.htm index.html...]
So, I guess I need to know what is the best way to redirect the explicit calls for the index.html files that come from the search engines.
Does this sound like a good way to do this? [I don't want to parse html as php... I know all about that and I don't want to do it that way, speed or parsing aside...still don't...]
What code would I have to put in the /public_html/.htaccess file to accomplish this -- keeping what pleases the search engines (e.g. Google) in mind?
Thanks for helping me with this. I've read dozens of posts around the net, and tried to make sense of documentation that is a bit confusing for me.
Here is some code (for a .htaccess file) that I am considering, if it will do what I've explained above:
Hmm, there are two ways to do this. Neither of them involves redirecting html pages to php pages.
One way is to parse all pages as if they included PHP, as mentioned above. This does cause a bigger workload for your server.
The other way is to simply have either an index.html or an index.php file in each folder, but not both and then include both index.php and index.html in the list of valid DirectoryIndex files. The final part to make this work is that incoming links should only link to the folder name and not mention the file name at all. That is, link to www.domain.com/folder/ and let the server find and serve the default page in that folder, whatever it may be. You don't need to know what that file is actually called, neither do visitors, and neither do search engines. Make sure that each folder contains an index.phpor an index.html file for this to work.
With all due respect, and said with a smile, parsing html as php is not SEO-friendly -- and an old 'bandaid' method used that has since been replaced by SEO-friendly redirect methods.
In order to keep the standing with the SE, you must retain the index.html file, though redirect it (in the correct, SEO manner) to the new index.php file (which resides in the same dir).
A SE call to a directory (e.g. h**p://www,thedomain.com/) is not the same as an explicit call to the index.html file (e.g. h**p://www.thedomain.com/index.html). Though, the result is the same, depending upon the DirectoryIndex order prescribed in the httpd.conf file, they are separate records in a SE database.
So, simply replacing the index.html with a index.php file is not a good SEO practice.
Thank you for your input, and I look forward to more posts with ideas about doing this which are in keeping with good SEO redirect practices.
I've had several sites for several years that have had static .html pages--and they have a lot of good links going to them. Those pages have ranked well for their keywords for over 5 years now. About a year ago I decided to start using php because I wanted additional functionality on those html pages. I kept the .html file extensions (thus the URLs didn't change)--parsing the differently allowed me to keep the rankings and enjoy the benefits of PHP. The PHP pages include both html tags and php scripting functionality.
Keeping the same URLs far outweigh the potential issues with using a redirect.
The decision to keep the same URLs should be based on current rankings of those .html pages and how difficult it would be to change the links going to those pages. If all the links are mostly internal, then there really wouldn't be a problem. But, with links from other sites to internal pages, it's almost imperative that you keep the same URLs to keep current rankings.
Google, for example, prefers (per their documentation and staff) a permanent 301 redirect. The redirects (new files) are updated during the next crawl. The redirects work with other sites that the links appear on. Clicking them there has the same affect.
If I were going to do a rewrite, I would use the following code in the httpd.conf file:
That keeps the same url and but doesn't require non-php files to be parsed as php files. Smarter huh?
"With all due respect, and said with a smile, parsing html as php is not SEO-friendly"
Where did you get this idea from, it's really not right. Parsing html as php just parses html as php, it's totally unconnected to seo, what is output is html, that's what the browser, search spider or whatever gets, makes no difference at all if the page is parsed or not.
As for worrying about server load by switching all pages to php parsing, which is the easiest way to do it by far, maybe if you're getting very heavy traffic and have a bad web hoster, but for most sites it's not visible at all.
Why make life complicated when you can make it easy? I think a lot of this server load worrying came from maybe about 5-10 years ago, where the servers really did have to do a lot more work with very limited ram and processor speed, that just isn't the case anymore, unless you are getting like 1,000,000 hits a day or something.
Plus, once you script one page, you might as well go ahead and script the whole site, it's easier to maintain longterm that way.
If it's a dedicated server you can put the html to php parsing directive in the httpd.conf file, that's more efficient than using .htaccess.
I am not sure if this is what you are looking to for but here is a way to parse php within an html file. Put the following lines in an .htaccess file and put it in the root directory.
You are not permitted to post messages in this forum or topic, because of one or more of the following reasons:
You have not yet logged in, or registered properly as a member
You are a member, but no longer have posting rights.
This is a private forum, for which you do not have permissions.
If you are a recent member, it's possible that you simply have not yet confirmed your account. Please
check your email for a message entitled 'JimWorld Forums: Confirm Your Account' and follow the instructions
contained within.
If you are still experiencing problem, please read the
Login Assistance
Article for some advice on what may be causing your login not to work properly.