Jump to content

.htaccess not working


gongpex
 Share

Recommended Posts

Hello everyone, I create code on .htaccess like this :

Option +FollowSymlinksRewriteEngine onRewriteRule ^(.*)\.htm$ $1.php [nc]

but it cause "Server Error" , when I put .htaccess file on the folder that contain file. What I must do to fix this problem? my purpose is to create url localhost/post/form.php into localhost/post/form please someone help me Thanks

Edited by gong
Link to comment
Share on other sites

Something like the following rewrite rule would take a link on your site, for example.. <a href="services" title="Services">Services</a> and display the appropriate page which would be services.php RewriteRule ^([a-zA-Z]+)/?$ $1.php [nc,l] So if you're trying to make form.php only have the word and no .php to it, you have to have the href for the links just contain the word for that particular page. So <a href="about" title="About">About Us</a>, when clicked on this link and if you contain a file called about.php where your .htaccess is at, it would display the about.php page but in the URL address bar for the browser, it will display something like this: http://www.site.com/about Hope this helps.

Link to comment
Share on other sites

Guest So Called

Here's an example from a site I know and respect:http://corz.org/serv/tricks/htaccess2.php

Options +FollowSymlinksRewriteEngine onRewriteRule ^(.*)\.htm$ $1.php [NC]

Looks like exactly the same file to me. So I doubt it's your code. I'm wondering if there's a character set problem. The server error (500? right?) indicates Apache is not happy with your file.

my purpose is to create url localhost/post/form.php into localhost/post/form
The codes you used will send reqiuests for form.htm to form.php.
Link to comment
Share on other sites

Looks like exactly the same file to me. So I doubt it's your code. I'm wondering if there's a character set problem. The server error (500? right?) indicates Apache is not happy with your file.
I ever try using simple .htaccess code like this :
Option +FollowSymlinksRewriteEngine onRewriteRule ^ try.php test.php [nc]

Before I using apache2triad 1.5.4 , I use apache2triad 1.4.3, and this code run successful on 1.4.3. Please see my attachment : apache.jpg Is this can cause trouble of server error 500? please someone help me Thanks

Link to comment
Share on other sites

Guest So Called

One thing about working with .htaccess files, when you get 500 server error almost all bets are off. It's like black magic, either you get it exactly right or it just fails and you have no idea why. I've often heard writing code as how many lines of code a good software author can write, debugged code, perhaps a dozen or a few dozen lines an hour? I consider it a good day if I can make a dozen lines of .htaccess (Apache) code work. I've sometimes spent a few hours just making one line of .htaccess work. My advice to everybody is to google "htaccess" or maybe "htaccess tricks" and read, read, read...

Link to comment
Share on other sites

you can check the error log of the server to see why does it failing

Link to comment
Share on other sites

Apache and Windows both have error logs and Apache has startup logs, request logs, etc. Nothing needs to be opaque, there's always a place to look for an error message. The software isn't just going to fail and not record why it did so in some place.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...