galvin Posted December 8, 2011 Share Posted December 8, 2011 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! Quote Link to comment https://forums.phpfreaks.com/topic/252751-rewriterule-not-working-for-one-page-only/ Share on other sites More sharing options...
galvin Posted December 8, 2011 Author Share Posted December 8, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/252751-rewriterule-not-working-for-one-page-only/#findComment-1295883 Share on other sites More sharing options...
galvin Posted December 8, 2011 Author Share Posted December 8, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/252751-rewriterule-not-working-for-one-page-only/#findComment-1295904 Share on other sites More sharing options...
requinix Posted December 8, 2011 Share Posted December 8, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/252751-rewriterule-not-working-for-one-page-only/#findComment-1295916 Share on other sites More sharing options...
galvin Posted December 8, 2011 Author Share Posted December 8, 2011 Had no idea about multiviews, thanks for sharing! I'll definitely use that Quote Link to comment https://forums.phpfreaks.com/topic/252751-rewriterule-not-working-for-one-page-only/#findComment-1295933 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.