LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-09-2009, 06:46 PM   #1
bittus
Member
 
Registered: Aug 2006
Posts: 153

Rep: Reputation: 16
redirect index.php to index.html


Hi all,

My site was running on php extensions till I modified it to use html extensions.

Now I want to redirect my pages to use index.html instead of index.php, as I don't want to loose the indexing in google and other search engines.

Example : Suppose my link is http://www.mydomain.com/index.php?op...d=71&Itemid=54

I want this link to be rewritten as http://www.mydomain.com/index.html?o...d=71&Itemid=54

Can someone help me on this ?
 
Old 12-09-2009, 07:53 PM   #2
RDove
LQ Newbie
 
Registered: Jul 2004
Posts: 22

Rep: Reputation: 16
Use a PHP script to redirect:

<?php
header("Location: http://www.domain.com/index.html");
?>
 
Old 12-09-2009, 09:29 PM   #3
bittus
Member
 
Registered: Aug 2006
Posts: 153

Original Poster
Rep: Reputation: 16
RDove - Thanks for your reply

But I am totally ignorant of the php stuff.

I thought we can do it with some Redirect conditions in httpd.conf.
 
Old 12-10-2009, 01:36 AM   #4
RDove
LQ Newbie
 
Registered: Jul 2004
Posts: 22

Rep: Reputation: 16
check this out, i think it does what you need

http://httpd.apache.org/docs/1.3/mod/mod_alias.html

Redirect permanent /index.php /index.html
 
Old 12-14-2009, 06:52 PM   #5
bittus
Member
 
Registered: Aug 2006
Posts: 153

Original Poster
Rep: Reputation: 16
Thanks to RDove for helping me on this issue.

Resolved the issue by adding the following to .htaccess.

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.php http://sitename.com/index.html [L,R=301]
 
Old 12-14-2009, 06:54 PM   #6
worm5252
Member
 
Registered: Oct 2004
Location: Atlanta
Distribution: CentOS, RHEL, HP-UX, OS X
Posts: 567

Rep: Reputation: 57
in your httpd.conf file you can set the DirectoryIndex to have html before php.

Code:
DirectoryIndex index.html index.php
 
Old 12-14-2009, 10:04 PM   #7
bittus
Member
 
Registered: Aug 2006
Posts: 153

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by worm5252 View Post
in your httpd.conf file you can set the DirectoryIndex to have html before php.

Code:
DirectoryIndex index.html index.php
Thats true, but an already indexed path will lead them into the php website itself. It seriously affects the rank of my website.

Anyway thanks for the reply
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change the default webpage configuration from index.php to index.htm, etc meema Linux - Server 4 08-22-2008 09:06 PM
Apache 404 index.php not Found but index.php exists at document root mark84 Linux - Server 20 07-27-2008 01:55 AM
apache index.html doesn't show up but index.php do zoffmann Linux - Server 5 01-28-2008 03:53 PM
Where to put index.php (or index.html) on Slackware 11.0 moonguide Slackware 3 05-08-2007 06:35 PM
Konqueror + file:/usr/share/doc/HTML/index.html jon_k Linux - Software 2 11-25-2003 05:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration