Asked By
Jim Crowley
0 points
N/A
Posted on - 08/25/2011
Hi all,
I have to change the display of the PHP files extension as html files like .html on the address bar on the browser. I am using the following code for this in text file and save it as .htaccess.
RewriteEngine On
RewriteRule ^(.*)-([0-9]+).html$Â viewstudent.php?id=$2
RewriteRule aboutus.html$Â aboutus.php
RewriteRule careers.html$Â careers.php
RewriteRule services.html$Â services.php
RewriteRule consulting.html$Â consulting.php
RewriteRule enquiry.html$Â enquiry.php
RewriteRule contactus.html$Â contactus.php
Unfortunately it is not working. It just shows PHP file extension only when I test. Is there any problem in my code, please suggest me, if any one can do.
Thanks,
Jim Crowley
File not working properly in my server .htaccess
Hi Jim,
I would like to say that your coding was great. But there was a problem in your coding. But I can’t give you the exact problem with your coding. Because I don’t know what the exact you want in your application. Base in your letter I seeing that you’re having a problem in your ending of your coding.
So I or you can suggest revise your coding or review you’re coding before you run it. Just try to analyse the exact coding and your code address name. Often times this error occurred when we did wrong in our coding flow. So review all our code then you can find the exact error.
Thanks,
Answered By
mughal
5 points
N/A
#118657
File not working properly in my server .htaccess
Apache Web Server .htaccess File Configuration Not working by Vivek Gite on March 19, 2008 · 9 comments
Q. I'm using CentOS Linux server with Apache 2 and PHP. I've created .htaccess file for URL rewriting and other configuration options. However, my Apache version 2 .htaccess configuration is not working at all. How do I fix this problem?
Â
Q. .htaccess is Apache's directory-level configuration file. It allows end user to configure authentication and other options without editing main httpd.conf file. Make sure AccessFileName set to .htaccess.
Â
Search httpd.conf for AccessFileName directive. It defines name of the distributed configuration file:
Â
-
# grep -i AccessFileName httpd.conf
Â
Make sure users are allowed to use .htaccess file.
Â
What you can put in these files is determined by the AllowOverride directive. This directive specifies, in categories, what directives will be honoured if they are found in a .htaccess file. If this directive is set to None, then .htaccess files are completely ignored. In this case, the server will not even attempt to read .htaccess files in the file system.
Â
-
# grep -i AllowOverride httpd.conf
Â
When this directive is set to All, then any directive which has the .htaccess Context is allowed in .htaccess files:
Â
-
AllowOverride ALL
-
Save and close the file. Restart httpd:
-
# service httpd restart