I have a Wordpress on a main domain which works fine but just installed CodeIgniter 3 on a subdomain and I keep getting Additionally, a 403 Forbidden error on CodeIgniter. I have played around with .htaccess with no success. Here is my .htaccess as it now
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
Did you try deleting the .htaccess in application folder?
You can try pasting this in your principal .htaccess
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]
This htacces only will work if your remove the /index.php/ from your url's
Related
I have an issue with Wordpress installed in subdirectory of root and https.
The most I could get is to have frontend fully working over https, but the /wp-admin cannot be accessed due to redirection loop.
my wp current setup:
FTP root structure:
/.htaccess
/main-domain.com (WP folder with same name as the domain name)
/subsite-1.main-domain.com (3rd level domains, no connection to WP)
/subsite-2.main-domain.com
/...
root .htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?main-domain.com$
RewriteCond %{REQUEST_URI} !^/main-domain.com/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /main-domain.com/$1
RewriteCond %{HTTP_HOST} ^(www.)?main-domain.com$
RewriteRule ^(/)?$ main-domain.com/index.php [L]
# subdomain redirects
RewriteCond %{HTTP_HOST} ^subsite-1.main-domain.com$ [NC]
RewriteCond %{REQUEST_URI} !^/subsite-1.main-domain.com/.*$
RewriteRule ^(.*)$ /subsite-1.main-domain.com/$1 [L]
wordpress .htaccess (/main-domain.cz/.htaccess)
RewriteEngine On
RewriteBase /
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
/main-domain.com/wp-config.php
define('WP_SITEURL','https://main-domain.com');
define('WP_HOME','http://main-domain.com');
// with WP_HOME set to "https://..." the site falls to redirection loop
I guess I just can't get my htaccesses straight, but also I'm afraid I'm "fighting" with WP internal redirects.
Two main things I want to achieve is the site to always be redirected to https and the folder name (/main-domain.com/) not to be seen in URL
I have site with 2 other sites in subfolders
https://example.com/
https://example.com/demo1
https://example.com/demo2
All 3 sites are actually wordpress installations.
The problem is: when I opened a page
https://example.com/demo1/testpage
I got redirected to
https://example.com/testpage
Contents of example.com/.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I've tried to add one more RewriteCond before RewriteRule (one line at a time):
RewriteCond %{REQUEST_URI} !demo1
RewriteCond %{REQUEST_URI} !^/demo1/(.*)$
RewriteCond %{REQUEST_FILENAME} !demo1
RewriteCond %{REQUEST_FILENAME} !^/demo1/(.*)$
But none of this worked.
So how to make it work and avoid redirect?
It's very strange but solution was to resave site url in wordpress settings on /demo1/wp-admin/options-general.php
I have installed word press in the public html folder of my hosting. I have put my old codeigniter site files into "oldsite\codeigniter". But i am unable to access this code igniter website always getting page not found error from word press
Sample URL : example.com/oldsite/codeigniter
How can i redirect to sub folder if the URL contains "oldsite" or oldsite/codeigniter
RewriteEngine On
RewriteRule ^oldsite/codeigniter/(.*)$ example.com/oldsite/codeigniter/$1 [NC,R=301,L]
codeigniter htaccess file
RewriteEngine on
RewriteCond %{REQUEST_URI} !(.gif|.jpg|.png)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteRule codeigniter/home$
example.com/oldsite/codeigniter[L,R=301]
This should be a comment, but is a bit too long.
To reiterate the initial setup: Wordpress is installed in the document root, public_html. And there's an old CodeIgniter website, which is installed in public_html/oldsite/codeigniter.
There should be just two .htaccess files necessary, one for Wordpress and one for CodeIgniter. Both are taken from their respective websites, https://codex.wordpress.org/htaccess and https://codeigniter.com/user_guide/general/urls.html
# /public_html/.htaccess
# Wordpress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# /public_html/oldsite/codeigniter
# CodeIgniter
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
If this fails for some reason, it might be that Apache is confused because of the relative path index.php. If this is the reason, you can fix it by using an absolute path, e.g.
RewriteRule ^(.*)$ /oldsite/codeigniter/index.php/$1 [L]
or add a RewriteBase directive
RewriteBase /oldsite/codeigniter
I have these working rewrite rules :
# Allow access to assets folder from plugins folders
RewriteRule ^app/plugins/(.+)/assets - [L]
# forbid access to files and folders under app
RewriteRule ^app/.*$ - [L,F]
# rewrite to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?action=$1 [L,QSA]
Now I would like to exclude from these rules everything located under http://www.mywebsite.com/wordpress/...
Therefore I've added a new rewrite condition :
...
# rewrite to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^\/wordpress\/ [NC]
RewriteRule ^(.*)$ index.php?action=$1 [L,QSA]
But it dosen't work. When I try to access something like this :
http://www.mywebsite.com/wordpress/contact-us/
it redirects me to index.php...
Any help would be really appreciated.
Ok I finally found what was going wrong with all of this :
In fact I did not notice that a .htaccess file was present in my /wordpress directory.
So on the .htaccess of my root directory I've added this rule on top of all the others :
RewriteRule ^wordpress - [L]
Then in the .htaccess of the wordpress directory I've these rules :
RewriteBase /wordpress/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
I don't know if everything is optimized but it works !
I'm working on a client app and im using the Slim framework.
the root of the site is a wordpress page
and my app stuff is under
http://example.com/yumninja_app_1_0/api/
when you go to the url, it returns a 404, but the 404 is from the wordpress page.
the htaccess file on the root is:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
and the htaccess inside my folder (yumninja_app_1_0/api/) is
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
My question is how to exclude a folder from mod_rewrite?
Add this line before RewriteRule
RewriteCond %{REQUEST_URI} !^/(yumninja_app_1_0|yumninja_app_1_0/.*)$