issues with Mod Rewrite with folders inside wordpress page - wordpress

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/.*)$

Related

.htaccess redirect to same subfolder

My problem is the following: My company shares hosting with others, and we have the subdomain inside a "public_html" folder. I can enter the index of my page perfectly, that is in www.principal.com/mypage it enters perfectly.
The problem is when I redirect to pages within my subdomain, they redirect to the 404 Not Found of the main page, that is to say www.principal.com/mypage/new 404 Not Found page of principal.com
The main / public_html / .htaccess file 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>
The file public_html/mypage/.htaccess is
<FilesMatch ".(phtml|php|PhP|php5|suspected)$">
Order Allow,Deny
Allow from all
</FilesMatch>
The file public_html/mypage/public/.htaccess is
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
I must clarify that my subdomain worked perfectly until a few days ago, since March that it worked very well.
Wordpress is the main page of the domain, my page in the subdomain is with the Laravel framework.
So, I redirect from Laravel to Laravel whit
Route::group([
'middleware' => 'auth'],
function(){
Route::get('/onepage', 'HomeController#one');
Route::get('/twopage', 'HomeController#two');
});
Your problem is because the directives in the root level .htaccess are used even something might be directed to the site in the subfolder. Try something like this in public_html/.htaccess, to exclude requests sent to the subfoler:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_URI} !^/autorizaciones/.*
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
I solved it
I changed The file public_html/mypage/.htaccess is
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /MYPAGE
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>

redirect WordPress website and hide sub-directories at URL

I'm not expert using .htaccess
I need to direct any request at our website abutair.net, to open first WordPress workplace, then hide sub- folders at URL, such as an example below:
https://abutair.net/about-us/
Instead:
https://abutair.net/innerPages/wordpress-4.7.4/wordpress/about-us/
I've wrote at .htaccess of website root folder, the following:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?abutair.net$
RewriteCond %{REQUEST_URI} !^/innerPages/wordpress-4.7.4/wordpress/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /innerPages/wordpress-4.7.4/wordpress/$1
RewriteCond %{HTTP_HOST} ^(www.)?abutair.net$
RewriteRule ^(/)?$ innerPages/wordpress-4.7.4/wordpress/index.php [L]
</IfModule>
and at .htaccess WordPress inner folder, the following:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /innerPages/wordpress-4.7.4/wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /innerPages/wordpress-4.7.4/wordpress/index.php [L]
</IfModule>
# END WordPress
It direct successfully to WordPress pages, but the sub-folders show at URL.
Please advice me how can solve this issue?
Thanks in advance,

Want to stop subdirectory from showing in urls

I've read a lot of threads on this topic, but I'm not very proficient at this stuff and nothing has worked for me.
I installed Wordpress in a sub directory and:
Changed the site address URL to the main domain in WordPress.
Then I copied the .htaccess and index.php to the root directory.
Then I changed the index.php file so that the require(‘wp/wp-blog-header.php’) pointed to the subdirectory.
Everything works, except the subdirectory shows in the URL, which I would like to hide.
The subdirectory I installed to is 'NA20H'. After changing the index.php file to point to it, this is what I have.
The .htaccess file in the Root directory reads:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /NA20H/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /NA20H/index.php [L]
</IfModule>
And the .htaccess in the subdirectory reads:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /NA20H/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /NA20H/index.php [L]
</IfModule>
What do I need to do in order to get 'NA20H' to stop showing in the URLs?
Thank you.
No need to copy index.php to root. Just follow these steps.
Put this in the .htaccess in the root.
RewriteEngine On
RewriteBase /
RewriteRule ^$ NA20H/ [L]
RewriteRule ^(.*)$ NA20H/$1 [L]
Put this in .htaccess in the NA20H folder
RewriteEngine On
RewriteBase /NA20H/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]

WordPress - redirect all pages to other domain and exception homepage and wp-admin

I need help with WordPress redirect. I think, that the simplest way is make this with htaccess file.
I want 301 redirect all pages from my site www.domain.com to subdomain web.domain.com, but I want have exception for homepage www.domain.com and for wordpress admin in www.domain.com/wp-admin/... and www.domain.com/wp-login.php
I have the basic wordpress htaccess settings:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
You can do:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule !^(wp-admin(/.*)?|wp-login\.php)?$ http://web.domain.com%{REQUEST_URI} [L,NC,NE,R=301]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Thanks for your help - I find, that I need both wp admin so I make this settings:
RewriteEngine on
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !/wpinstall(/.*)$
RewriteRule (.*) http://web.domain.cz/$1 [R=301,QSA]
And I install wp to subfolder wpinstall

Wordpress + Codeigniter htaccess confusing

I have Wordpress installed in the root directory with the following 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
and I have Codeigniter installed in a sub-directories named members, with the following htaccess :
RewriteEngine on
RewriteBase /members/
RewriteCond $1 !^(index\.php|images|templates|assets|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
When I try to access any controller via : site.com/members/controller/function I get the Wordpress 404 error page
In your CI config.php, set your base url as
$config['base_url'] = 'http://site.com/members/'
and change
RewriteBase /members/
to
RewriteBase /
in your CI .htaccess file. This way when you access CI, it doesn't look in the root (which is WP), it goes straight to it's directory and bypasses WP.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /cidir
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>

Resources