I have a small question.
I have build a system and it is using a .htaccess to direct the traffic to the correct locations.
Now I have the following .htaccess data
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ core/ [L]
RewriteRule (.*) core/$1 [L]
///### (does not work.. this is a problem) RewriteRule (.*) app/template/ !page [L]
</IfModule>
The problem is actually that when I want to show a .css file located in /app/templates it also redirects to /core/
I tried to make an exception. However that does not really seem to work at my method.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ core/ [L]
RewriteRule (.*) core/$1 [L]
RewriteRule (.*) app/template/ !page [L]
</IfModule>
This .htaccess gives a 500 error.
Could anyone tell me what I am doing wrong? And how I can make the exception work for the template directory?
TIAD!!
You should use:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ core/ [L]
# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) core/$1 [L]
</IfModule>
Related
This is my webroot .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteBase http://localhost/myproject/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
This is project folder .htaccess file
<IfModule mod_rewrite.c>
#RewriteEngine on
#RewriteRule ^(\.well-known/.*)$ $1 [L]
#RewriteRule ^$ webroot/ [L]
#RewriteRule (.*) webroot/$1 [L]
</IfModule>
This file is in app folder .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
Can any one help me out with this?
Try with below htaccess codes
/var/www/app/webroot/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
/var/www/app/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
/var/www/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
There can be following reasons for 500 Internal Server Error in CakePHP application:
1) Your .htaccess files are not correct.
2) Permissions of folders are not correct. If CakePHP app is Group Writable i.e. 777 then webserver gives 500 error for safety.
3) You are missing Database Connection. Correct database configuration according to Webhost because most of times local and production server databases have different details.
4) Delete the content of your tmp folder. It is best practice that you must delete cache if you move your application from one place to another.
5) For testing purpose debug should be on like configure::write('debug',2);
6) If not succeeded check your Apache Error Log. If using Linux /var/log/apache2/error.log
Hope It Helps, Thanks!!
I am building a php framework and at the moment i have these .htaccess rules for directing to my index and getting the controllers and arguments from the URL
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ /index.php/$1
But since the site is not ready yet I need to add a rule for when accessing root directly to forward to comingsoon.php
any idea how?
Add this rule before the other one. This matches www.site.com or www.site.com/
RewriteRule ^/?$ /commingsoon.php
Pasted from Symfony2 Framework .htaccess file (replaced app.php with index.php) but it should works. Try it:
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule .? %{ENV:BASE}/index.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 302 ^/$ /index.php/
</IfModule>
</IfModule>
Building a CakePHP website for a client, it runs perfectly on my local environment, and when being tested on my server. However, when I transferred it to the client's site5 server it returned nothing but 404 errors.
After some modifications to the .htaccess files I was able to get the default landing page working fine:
http://174.120.222.98/~sty/
The issue I have, is that only the default landing page can be found. All of the sub-pages are still returning 404 errors (example: "NEW STUDENTS" Green-background link in NavBar).
I've changed the root/.htaccess file to:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /~sty
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
without RewriteBase /~sty The default landing page is a 404.
I've changed root/app/.htaccess file to:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
Without this change, none of the files in webroot loaded (images/styles/js).
Those two files alone seem to be all I need for the default page, I can even remove the root/app/.htaccess file and the landing page looks great. So I'm assuming the app file is the one that will govern my sub-pages. Nothing I've done to it seems to work, it is currently set to:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /~sty
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
I've tried to RewriteBase with \, \~sty, \~sty\app and without the line so far none of my changes seem to work.
Help me StackOverflow, you're my only hope.
mod_rewrite is not enabled on your server so you have to handle this with .htaccess file in your root directory
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
and another .htaccess in your app folder
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
and another one in your webroot folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
First of all, I want to describe that I have researched a lot on this question so thats why I am asking so please dont downvote. I have implemented lot of solutions.
I am using cake2.0. I have uploaded a website on development server the link is http://dev.infideaco.com/eventmanager/ . But I am getting the not found error. I have resolved it by changing the .htaccess files but then the css,js and images are still not available.
I have .htaccess files which are provided by default installation. I am setting it up in development server
/var/www/dev.infideaco.com/eventmanager
The website is running fine on other servers.
You can check here:
http://swirlsyogurtbar.com/js/
These are the htaccess files:
root file:<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule sss (.*) app/webroot/$1 [L]
</IfModule>
in app:<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
app/webroot/.htaccess:<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Please provide me the solution. Lot of thanks in advance
I would first check if server supports mod_rewrite. Also check this thread if you haven't already: cakePHP - 404- page not found error, when deploying on a different machine
root file:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
in app:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
app/webroot/.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I am having an issue with the .htaccess file on a justhost.com account. I recieve constant internal 500 errors and I have tried many different solutions around the web. Here is what my htaccess files look like:
ROOT HTACCESS
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
app/ HTACCESS
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
app/webroot/ HTACCESS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
The issue is that I get this in the error log:
Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
Ive tried setting the RewriteBase to / but it doesnt correct the issue.
You have to use Rewrite base in three .htaccess files. The one in the root directory which contain directories app , lib , plugin and vendor should look like
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
The app / htaccess should look like
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /app/
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
And finally the app/webroot/htaccess should look like
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /app/webroot
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
If your lib is not in the root folder you will have to also the change the values in core.php to map it to relevant address. For that you can check out the advanced installation in the cook book.
Check your file permission.
Switch off your htacess file and write echo 1;exit; index.php and check weather it shows or not.