I have uploaded all my files on the Apache/2.2.3 (Red Hat) live server.
There is htaccess file on the root of website for converting php to html.

But it is not working and getting "Internal Server Error".

If i blank that htaccess code then it works.
I don't know what is issue and what to do. Help me out.

7 Years
Discussion Span
Last Post by pritaeas
Options +FollowSymLinks
RewriteEngine on
RewriteRule medical_tourism/(.*)/(.*) medical_tourism.php?facilityid=$1&$2[NC]
RewriteRule medical_tourism_directory.html medical_tourism_directory.php
RewriteRule login.html login.php

RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html

Little more explanation needed...
1. Whether you want to change all the .php files to .html or just the login.php to login.html?
2. R u trying to exec a php code inside an html?
3. If u want to change .php to .html then y use "RemoveHandler .html .htm"


1) i just want to rewrite medical_tourism.php , medical_tourism_directory.php and login.php to html extensions.

2) other than these three files all are html files and i have placed php code inside it.

3) i dont know reason :) i have just googled and that code works for me, so i have used it.

Instead of this htaccess code, i had tried just one line
"AddType application/x-httpd-php .php .htm .html" to run test page, test.html and echo 'Hello' in that page.
But even that also doesn't work.

Is there any kind of restriction? Do i have to contact host for use of htaccess?


So my understanding is that
1. You need to run a.html which is having php code inside.If so use the below code in .htaccess file.

RewriteEngine on
AddHandler application/x-httpd-php .html .htm

i have mentioned .htm just for your reference only okey.
2. To rewrite a url use the below mentioned code in .htaccess file.

RewriteRule medical_tourism.php http://fullpath/medical_tourism.html  [NC,L]

If you want to convert all the .php files to .html files use

RewriteRule ^(.*)\.php$ $1.html [L]

Edited by Manuz: n/a


Check to see mod_rewrite module is loaded - is the .so file is enabled in your httpd.conf file?

How did you get the .htaccess file to the server? Try FTPing the file as htaccess.txt, then renaming it to .htaccess directly on the server.


@Manuz: RewriteEngine on
AddHandler application/x-httpd-php .html .htm

Actually issue is not in htaccess code but htaccess file itself is not
working.Even this above two line is also not working

@storm123 : I have just uploaded my whole folder on live server.
.htaccess file is not visible in FTP. What i am doing is each time i
modify locally then reupload it and overwrite it.


>What i am doing is each time i modify locally then reupload it and overwrite it.

Try my suggestion of uploading the file as htaccess.txt then just renaming it. This solved a similar problem for me a few years back.

Another thing - does your host actually support .htaccess? Although it may be a Linux server, some hosts don't allow you to use .htaccess.

Edited by diafol: n/a


Hey thanks all for replying...
i got solution.
1)host support said: as php is running in CGI so i will not able to see mode_rewrite in phpinfo.
2)gbo is my subfolder, so i have added this line: RewriteBase /gbo/
3)RULE: RewriteRule medical_tourism/(.*)/(.*) medical_tourism.php?facilityid=$1&$2[NC]
was not working because there is one file on server named: 'medical_tourism.html'
so it is conflicting rule.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.