Jump to content
Sign in to follow this  
gongpex

.htaccess not working

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

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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...

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...