Reputation: 2674
i made a simple .htaccess file to expose the problem.
I want that all request made to the folder redirect to a subfolder file "app/index.php"
RewriteEngine On
RewriteRule (.*) app/index.php [QSA]
And this works fine on with the basic url of my hoster (like http//myname.hosting.com/htaccessFolder
The problem is that i have a domain pointing on this folder, and when accessed to it, server return Internal Server Error 500
.
If i do this :
RewriteEngine On
RewriteRule (.*) somefile.php [QSA]
Redirection works only when file does not exists (404 not found error occured). when the file exists i get a 500 error too.
I've asked the hosting support without success for the moment..
EDIT :
Strangely, when i write :
RewriteEngine On
RewriteRule (.*) somefile.txt [QSA]
it works on bot, so it seems that the problem comes from executing php files..
EDIT2 :
Here is the real .htaccess file i try to use :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#RewriteCond %{REQUEST_FILENAME} -f
#RewriteRule .? - [L]
#####################
RewriteRule (.*) app/public/$1
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule app/public/(.*) $1
#####################
#RewriteCond %{REQUEST_FILENAME} question2answers/(.+)
#RewriteRule .? - [L]
#####################
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteRule (.*) index.php [L,QSA]
</IfModule>
You can see that only the public block is not commented but when i go to the website i get this : The requested URL /cgi-bin/php5.fcgi/index.php/index.php/index.php/index.php/index.php/index.php/index.php/in.....
but i request a file in the public folder (like http://website.com/css/style.css (which is in public/css) it works as expected. When i'm not commenting the last block, i get a 500 error.
Upvotes: 0
Views: 912
Reputation: 2674
Ok, i found a solution to avoid redirections :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#####################
RewriteCond %{QUERY_STRING} stop
RewriteRule (.*) - [L]
#####################
RewriteCond %{REQUEST_URI} question2answers/(.*)
RewriteRule (.*) $1?htaccess=stop [L,QSA]
#####################
RewriteRule (.*) app/public/$1
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule (.*) $1?htaccess=stop [L]
RewriteRule app/public/(.*) $1
#####################
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) index.php?htaccess=stop [L,QSA]
</IfModule>
I do not understand all but it works.
Upvotes: 1
Reputation: 143916
Try adding in your htaccess file:
Options -Multiviews
It turns off content negotiation which can sometimes screw with how URLs map to files with extensions like php.
Upvotes: 0