Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
  • Register
Welcome to the Q&A for Question2Answer.

If you have questions about the platform, click here to ask and please use English.

If you just want to try Q2A, please use the demo, which also grants admin access.

Apr 29: Q2A 1.5.2

Suggestion for .htaccess enhancement

0 votes

I would suggest to enhance .htaccess a little bit.
My proposition:

 

# The following IF prevents "Error 500; Internal Server Error" if the server doesn't support rewriteBase.
<IfModule mod_rewrite.c>
AddType x-mapp-php5 .php
#AddHandler application/x-httpd-php5 .php
DirectoryIndex index.php
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php?qa-rewrite=$0&%{QUERY_STRING} [L]
</IfModule>
 
As long as RewriteBase should have always / as a value (even if the script is placed in some subfolder), "your-sub-folder" can be dropped.
 
Any more suggestions / upgrades ?

 

Q2A version: 1.5
asked Dec 30, 2011 in Q2A Core by Krzysztof Kielce

1 Answer

0 votes
Thanks for the suggestion. I will add the <IfModule...> wrapper for 1.5 beta 2, but RewriteBase should remain commented out by default, since it can break the .htaccess if the Q2A site is in a subdirectory. Also I am cautious about adding AddType/AddHandler directives because this doesn't seem to be an issue for anyone, and it could interfere with the Apache configuration.
answered Jan 1 by gidgreen
Okay. However, it is misleading to have "# RewriteBase /your-sub-folder" instead of "# RewriteBase /' - because only the second option will work both when the webside is placed in a rootfolder OR in a subfolder.

(I had such an experience. Maybe in some cases "your-sub-folder" would be needed, but I didn't find them).
Yes, you're right about that. Now it will be only: #RewriteBase /