Jump to content

rewriterule not working for ONE page only


galvin

Recommended Posts

This might  not be enough info for anyone to answer, but I am desperate so giving it a shot.  I am building an application locally and I am using mod_rewrite to display seo-friendly URLs.

 

I have a page called profile.php and I simply want the URL to show as mydomain.com/profile instead of mydomain.com/profile.php. I added this info to my .htaccess file...

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^profile /profile.php [NC,L] 
RewriteRule ^create/data /createdata.php [NC,L]

 

The "create/data" rewrite rule works perfectly.  But the profile one will not work.  I tried deleting every rule except that one, I tried commenting out the "Options" line, etc.  and everytime, I get this  500 Internal Server Error message...

 

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@mydomain.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

 

I tried deleting everything out of the profile.php page and it still happens, so pretty sure that means there is nothing wrong with profile.php page itself.

 

Anyone have any idea what I can check?  This is driving me absolutely nuts. :(  I'd rather it not work for any rules, but the fact that every other rule except this one works fine makes no sense.

 

Any suggestions on what to try would be incredibly appreciated!

 

Link to comment
Share on other sites

UPDATE INFO (which may or may not help)...

 

I removed the .htaccess file completely and went directly to the profile.php page and it worked.

 

I then put the .htaccess file back and went directly to the profile.php page again and it gave the 500 internal server error.

 

So it seems like the rewriting isn't the problem, but the htaccess file clearly is involved since there are no problems until that file exists.

 

How could the htaccess file break one simple page, while all others in my application work fine?

Link to comment
Share on other sites

One more UPDATE.  This is from my server's error log.  Maybe it will help?....

 

[Thu Dec 08 12:57:41 2011] [alert] [client 24.187.116.213] /home/me/public_html/mydomain.com/.htaccess: Invalid command '\xa6sending', perhaps misspelled or defined by a module not included in the server configuration

Link to comment
Share on other sites

Assuming the .htaccess is syntactically valid, the problem is the rewriting. Riddle me this: does "profile.php" match the expression "^profile"? It does.

Common misconception: the [L] flag does not stop rewriting entirely. Only the current round. Apache and mod_rewrite are free to restart the entire process again, and will because you've given them new URLs to serve up.

 

You don't need mod_rewrite just to remove file extensions. Use MultiViews.

Options +FollowSymLinks +MultiViews

Note: That will also allow other recognized file types (images, CSS, etc.) to go extensionless. If you have more than one file with the same name but different extension then there may be problems.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.