Htaccess Qsa Internal Server Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the
Rewriteengine On 500 Internal Server Error
workings and policies of this site About Us Learn more about htaccess redirect 500 internal server error Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions internal server error htaccess rewrite Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
Apache2 Enable Mod_rewrite
Join them; it only takes a minute: Sign up .htaccess - Clashing rules causing internal server error up vote 1 down vote favorite I'm tying to add a section to our website which is heavily powered by a .htaccess file. Currently I have a rule which handles rewrites if there is only one part after the domain so something
Rewritebase
like the following will cause the site to search for a page called 'theteam'. https://very-pc.co.uk/theteam This works well but I'm now trying to add a section which will have the following address: https://very-pc.co.uk/products The trouble is when I add a rule for this (making sure it's above the previous rule) it causes a 500 Internal Server Error. If I have one rule or the other it works perfectly but the problem comes when both rules are present. It's a little hard to explain so here is the problem code: RewriteRule ^products/?$ ?cat=top-level-summary&page=products [QSA] RewriteRule ^([^/]+)/?$ /?cat=generic&page=$1 [QSA] And the full .htaccess file: # Error Handling ErrorDocument 403 /index.php?cat=error&page=403 ErrorDocument 404 /index.php?cat=error&page=404 ErrorDocument 500 /index.php?cat=error&page=500 ErrorDocument 503 ?cat=error&page=503 # For security reasons, Option followsymlinks cannot be overridden Options +FollowSymLinks +SymLinksIfOwnerMatch - indexes -MultiViews # Turn the rewrite engine on RewriteEngine On # Set the root of the folder to structure ReWriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f # Start the mod re-write conditions # Redirect short URLs RewriteRule ^broadleaf/?$ /products/desktops/broadleaf-one [R=301] RewriteRule ^broadleafone/?$ /product
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about apache rewrite rules Stack Overflow the company Business Learn more about hiring developers or posting ads with
Apache Mod_rewrite
us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up RewriteRule creating 500 Internal Server Error up vote 4 down vote favorite I have the http://stackoverflow.com/questions/25306194/htaccess-clashing-rules-causing-internal-server-error following in my .htaccess file: Options +FollowSymLinks RewriteEngine on RewriteRule ^directory/(.*)$ directory/index.php?id=$1 What I'm trying to achieve is this: When the URL www.mydomain.com/directory/10 is visited, the page www.mydomain.com/directory/?id=10 is displayed on the browser without altering the appearance of the URL. The above code creates a 500 Internal server error though. Does anyone know where I'm going wrong? php apache .htaccess mod-rewrite share|improve this question asked Jun 14 '13 at 11:56 http://stackoverflow.com/questions/17107940/rewriterule-creating-500-internal-server-error Tom 4,3042697174 1 A 500 error generally means an error has been logged somewhere. Find your Apache and PHP error logs, and see what the actual error is. –IMSoP Jun 14 '13 at 11:58 4 The 500 error delivered to the browser should have informed you that the full error message would be in the server logs. Read them. –Quentin Jun 14 '13 at 11:58 add a comment| 4 Answers 4 active oldest votes up vote 9 down vote accepted Your code is guaranteed to generate 500 internal server error because it is causing infinite looping. Reason is that your matching URI pattern is: ^directory/(.*)$ Which matches your URLs before and after rewrites. And once it reaches max allowed internal rewrite limit Apache throws 500 internal server error and bails out. Change your code to this: Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^directory/(.*)$ /directory/index.php?id=$1 [L,QSA,NC] Above code has an extra RewriteCond %{REQUEST_FILENAME} !-f that will make sure to disallow subsequent execution of RewriteRule after first time since /directory/index.php will be a valid file. share|improve this answer answered Jun 14 '13 at 12:39 anubhava 384k32160232 1 That is brilliant! Thank you. –Tom Jun 14 '13 at 12:44
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack http://stackoverflow.com/questions/6201174/htaccess-internal-server-error Overflow the company Business Learn more about hiring developers or posting ads with us http://stackoverflow.com/questions/14265724/htaccess-file-not-responding-internal-server-error-500 Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up htaccess internal server error up vote 2 down vote favorite When I goto http://example.com/not-here I internal server get an internal server error instead of an 404, here is my htaccess file (it removes the extension so abc.php can be accessed as example.com/abc instead of example.com/abc.php): Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)$ /$1.php [L,QSA] DirectoryIndex login.php index.php ErrorDocument 403 /error.php?type=403 ErrorDocument 404 /error.php?type=404 ErrorDocument 500 /error.php?type=500 Its proberly something really simple but I cannot see it, any help is appriciated .htaccess internal server error mod-rewrite internal-server-error share|improve this question asked Jun 1 '11 at 12:31 Kyle Hudson 6521127 1 What is in the apache logs? –akond Jun 1 '11 at 13:00 @akond: I cannot access the logs its on a shared server –Kyle Hudson Jun 1 '11 at 13:45 add a comment| 3 Answers 3 active oldest votes up vote 3 down vote accepted I should have in the .htaccess the following: Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteCond %{QUERY_STRING} !rewrited RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)$ /$1.php?rewrited=1 [L,QSA] DirectoryIndex login.php index.php ErrorDocument 403 /error.php?type=403 ErrorDocument 404 /error.php?type=404 ErrorDocument 500 /error.php?type=500 share|improve this answer answered Jun 1 '11 at 16:12 akond 7,99632142 Thanks @akond +1 –Kyle Hudson Jun 1 '11 at 17:18 add a comment| up vote 1 down vote What I do when I run into this is comment out lines. Comment out the rewrite section and see if that works. To comment out code just put a # as the first character. It's all about narrowing the code down to the culprit line. share|improve this answer answered Jun 1 '11 at 13:53 Justin 313 its the "RewriteRule ^(.+)$ /$1.php [L,QSA]" which is causing it, any suggestions? –Kyle Hudson Jun 1 '11 at 1
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Htaccess file not responding - Internal Server Error 500 up vote 0 down vote favorite I am having trouble with .htaccess file, essentially I am just trying to rewrite the urls to be a bit more user friendly. So what I have for a url currently is something like this: http://diverseevolution.com/index.php?url=about What I want is something like this: http://diverseevolution.com/about/ Finally I have written my own .htaccess file that looks like this: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] Now I have tested this in other directories of my server and it works fine but under an actual domain and not just a sub directory it gives me a Internal Server Error 500 Any help with this would be greatly appreciated! .htaccess mod-rewrite friendly-url internal-server-error share|improve this question edited Nov 17 '15 at 18:26 pnuts 33.9k63769 asked Jan 10 '13 at 19:25 Tom Bird 4071623 What does your apache error log say? –h2ooooooo Jan 10 '13 at 19:31 add a comment| 2 Answers 2 active oldest votes up vote 1 down vote accepted You may try this: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} ([^/]+)/? [NC] RewriteRule .* index.php?url=%1 [L,QSA] It will map silently: http://diverseevolution.com/anything/ To: http://diverseevolution.com/index.php?url=anything share|improve this answer answered Jan 10 '13 at 19:41 Felipe Alameda A 10.1k21329 Thanks so much!!!! I actually only need to add the rewrite base to the file and it did everything else for me. pre``RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] –Tom Bird Jan 10 '13 at 20:39 add a comment| up vote 0 down vote RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l