File not working properly in my server .htaccess

Asked By 0 points N/A Posted on -
qa-featured

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

SHARE
Best Answer by jamesfrance
Best Answer
Best Answer
Answered By 0 points N/A #118656

File not working properly in my server .htaccess

qa-featured

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 5 points N/A #118657

File not working properly in my server .htaccess

qa-featured

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

Related Questions