Configuring .htaccess files for CakePHP and Wordpress - php

I have already visited this link:
Configure .htaccess file for multiple environments
But it hasn't resolved my problem.
I am unable to access CakePHP folder from Wordpress directory. This is the .htaccess file of my root:
RedirectMatch 404 /\\.svn(/|$)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /myer
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /project/trunk/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /project/trunk/index.php [L]
</IfModule>
# END WordPress
This is the .htaccess file of "myer" directory:
RedirectMatch 404 /\\.svn(/|$)
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /myer
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
This is the .htaccess file of "myer/app" directory:
RedirectMatch 404 /\\.svn(/|$)
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /myer
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
This is the .htaccess file of "myer/app/webroot" directory:
RedirectMatch 404 /\\.svn(/|$)
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /myer
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
What I am getting out of these .htaccess files is "Object not found! - Error 404". What am I doing wrong?

Related

Error in Cakephp 2.8.4 as sub-directory inside a core PHP website

I am getting the error(mysite.com/cake-284/users/login):
404 - File or directory not found.
-after uploading the Cakephp 2.8.4 sub-directory to my PHP website in the live host.
But the subdirectory root(mysite.com/cake-284) shows:
500 - Internal server error.
The site is running fine in the localhost by the wamp server (PHP Version 5.5.12).
I believe this is the problem of my .htaccess file(s). After searching for a solution, I found Set up CakePHP in a subdirectory; Wordpress is installed in the root, and cakephp inside a subdirectory. But these didn't help.
There is no .htaccess file in the root.
mysite.com/cake-284/app/webroot/.htaccess :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
mysite.com/cake-284/app/.htaccess :
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
mysite.com/cake-284/.htaccess :
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Cakephp 2.8.6, PHP Version: 5.5.35
I don't know if there is anything else to do with the rewrite.
Edit .htaccess with you sub directory
mysite.com/cake-284/app/webroot/.htaccess :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /cake-284
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
mysite.com/cake-284/app/.htaccess :
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /cake-284
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
mysite.com/cake-284/.htaccess :
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /cake-284
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>

Rewrite rule in htaccess - Inner pages of my website not loading however home is loading correctly

askpapa.in/askpapaFinal is opening fine.
See the problem here
root htaccess file
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /askpapaFinal/
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
App Folder Htaccess file
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /askpapaFinal/
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
webroot htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /askpapaFinal/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

Error 500 MVC with subdomain

I have a PHP MVC frame work.
I created a subdomain but it gives the error 500.
My root .htaccess file is like this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ all_users/ [L]
RewriteRule (.*) all_users/$1 [L]
It redirects to the "all_users" folder.
The "all_users" root .htaccess is like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
The subdomain folder is in root of site.
How should I change the .htaccess file(s) for subdomain
redirection. Thanks.
I found the answer.
This is the .htaccess file in root of site:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^subdomain.domain.com$ [NC]
RewriteRule (.*) / [L]
RewriteRule ^$ all_users/ [L]
RewriteRule (.*) all_users/$1 [L]
</IfModule>

.htaccess Issue : 404 for index

This is my .htaccess file in sub-folder...
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteRule (.*) ./index.php?id=$1 [L]
</IfModule>
I want mydomain.com/sub-folder/string to processed by index.php as mydomain.com/sub-folder/?id=string
But I am getting 404... not sure why. This is my root .htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Keep your root .htaccess as:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(index\.php|sub-folder(/.*)?)$ - [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
# END WordPress
And keep this in /sub-folder/.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /sub-folder/
RewriteRule ^index\.php$ - [L,NC]
RewriteRule (.+) index.php?id=$1 [L,QSA]
</IfModule>

.htaccess rewrite parent folder to sub folder

how can i redirect from server.ip/~bogo/api/* to server.ip/~bogo/api/public/*?
any help please
Here's htacces in api directory
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
my htacces in public directory
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
</IfModule>
but i got 404 error??
Ok i solved it here's my solution
api directory htaccess
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /~bogo/api/
RewriteCond %{REQUEST_URI} !/public/
RewriteRule (.*) public/$1
</IfModule>
public directory htaccess
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /~bogo/api/public/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
</IfModule>
Apache will go through .htaccess until no rules match anymore. The problem you are most likely facing, is that the new url is being matched by the regex of the same rule. You have created an infinite loop. You can fix this by making sure the rule doesn't match if the url already has 'public' in it:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !/public/
RewriteRule (.*) public/$1 [L]
</IfModule>

Categories