How to exclude a folder from my htaccess command - wordpress

I have the followind htaccess in my main root... but I want to exclude a subdomain folder to install a wordpress... actually the wordpress im trying to install is giving error ,, when I remove this htaccess the wordpress works fine... thanks
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
# Get rid of index.php
RewriteCond %{REQUEST_URI} /index\.php
RewriteRule (.*) index.php?rewrite=2 [L,QSA]
# Rewrite all directory-looking urls
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*) index.php?rewrite=1 [L,QSA]
# Try to route missing files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} public\/ [OR]
RewriteCond %{REQUEST_FILENAME} \.(jpg|gif|png|ico|flv|htm|html|php|css|js)$
RewriteRule . - [L]
# If the file doesn't exist, rewrite to index
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?rewrite=1 [L,QSA]
</IfModule>

To exclude a file from htaccess, you can place an htaccess file in the directory with a simple:
RewriteEngine On
Otherwise, in the root folder's htaccess file, you can add this right below the RewriteEngine On:
RewriteRule ^directory_you_want_to_protect - [L]
But I suspect that this is really a XY Problem here. You're probably going to need to rework or combine the htaccess rules that wordpress requires with the ones that you have right now. They may not be entirely compatible. If it's a matter not being able to run the installer, simply remove the root's htaccess file temporarily, install wordpress, then figure out how to combine the rules.

Related

How to remove index.php from CodeIgniter3 install in subdirectory with Wordpress on root?

So the title of the question was a little difficult to come up with. Here's the deal, the CI3 install is like this: www.mydomain.com.au/apps/TGPS where TGPS is the CI application. Additionally, on the root of the web folder there is a Wordpress install. My question is, what is the .htaccess setup that I need to compress the URLs from:
www.domain.com/apps/TGPS/index.php/controller/function
to this:
www.domain.com/apps/TGPS/controller/function
At present I have this:
The top level .htacess is this:
# BEGIN WordPress
RewriteRule ^/apps($|/) - [L]
# END WordPress
The .htaccess in TGPS is this:
<IfModule mod_rewrite.c>
RewriteEngine On
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css folders, and the robots.txt file
RewriteCond $1 !^(index\.php|public|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
and the .htaccess in application is the standard one.
Seems everything I try either breaks Wordpress, CodeIgniter or has no effect. Any help would be appreciated.
At first glance, you're missing a rewrite base:
RewriteBase /apps/TGPS/
Try bellow code
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php
RewriteRule ^index\.php$ / [L,R=301]
Then the www to non-www:
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]

How can I fix this HTACCESS to allow Sub Folder Installation of WP (and it's own htaccess modrewrite rules)

I have a application that uses rewrite conditions, and then I added wordpress. I could not get /blog to rewrite properly.
Please see below for both HTACCESS files in root, and /blog (where wordpress is installed). I need to create a reference in root to allow /blog to work properly (im guessing). But how can I do this without breaking my other rewrite rules?
/.htaccess
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.example.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?sn=$1 [QSA,L]
#RewriteRule ^([a-zA-Z0-9/%-]+)$ index.php?sn=$1 [QSA]
Then in wordpress my wordpres install folder, i am simply doing:
/blog/.htaccess
#for blog directory only
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
... and all other rw conditions needed for caching, etc
The reason the error was persistent with this dual HTACCESS setup was because the /blog/.htaccess file was missing an additional line:
RewriteRule . /blog/index.php [L]
Once added, it operated fine. No chances needed to go into the root htaccess to reference the /blog/ rewrite conditions. This allows for a wordpress install in a blog folder, and above references dual HTACESS rules

.htaccess work for domain but not for subdomains

I have a vbulletin with vbseo installed and the .htaccess code is
# Comment the following line (add '#' at the beginning)
# to disable mod_rewrite functions.
# Please note: you still need to disable the hack in
# the vBSEO control panel to stop url rewrites.
RewriteEngine On
# Some servers require the Rewritebase directive to be
# enabled (remove '#' at the beginning to activate)
# Please note: when enabled, you must include the path
# to your root vB folder (i.e. RewriteBase /forums/)
#RewriteBase /
#RewriteCond %{HTTP_HOST} !^www\.yourdomain\.com
#RewriteRule (.*) http://www.yourdomain.com/forums/$1 [L,R=301]
RewriteRule ^((urllist|sitemap_).*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]
RewriteCond %{REQUEST_URI} !(admincp/|modcp/|cron|vbseo_sitemap|api\.php)
RewriteRule ^((archive/)?(.*\.php(/.*)?))$ vbseo.php [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !/(admincp|modcp|clientscript|cpstyles|images)/
RewriteRule ^(.+)$ vbseo.php [L,QSA]
the sub-domains have wordpress on it for example : games.domain.com not working it gives me Internal Server Error
so how to resolve this issue? and get's the domain and sub-domains work ?
I solve the problem by adding .htaccess file into games folder with the following code only
RewriteEngine Off

wordpress .htaccess rewrite loop with prev domain redirect

I have 1 hosting with root htaccess for redirect to a specific folder for a specific domain
works perfect.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain1.com$ [NC]
RewriteCond %{REQUEST_URI} !folder1/
RewriteRule ^(.*)?$ /folder1/$1 [L]
RewriteCond %{HTTP_HOST} ^domain2.com$ [NC]
RewriteCond %{REQUEST_URI} !folder2/
RewriteRule ^(.*)?$ /folder2/$1 [L]
on folder1 i have a wp folder with wordpress installation
on www/folder1/wp/.htaccess i have
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp/index.php [L]
</IfModule>
# END WordPress
if i go http://domain1.com/wp/ everethings works perfect
BUT if i dont´t put the last slash http://domain1.com/wp and leave just the folder gets in a redirect loop.
Can someone help me please
Thanks
Note that your WP rules do not handle the ^$ condition. I suspect that your hosting provider has a default DirectoryIndex. It doesn't really matter what this is, say it matches to index.html, then on a subrequest wp:rule2 will convert this to wp/index.php -- a case of two wrongs accidentally making a right. But this all goes wrong in the case of wp, because in this case %{REQUEST_FILENAME} is a directory.
The safest thing to do here is to explicitly handle the ^$ case by adding the rule
RewriteRule ^$ index.php [L]
as rule 2 to the wp/.htaccess.

How do I combine WordPress permalink code and .htaccess redirect?

I'm trying to combine the following code so that the WordPress permalinks work in the main directory, waringis.com (top code) and a second domain, burrowpress.com, is redirected to the subdirectory 'waringis.com/burrowpress' (bottom code) -
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
RewriteEngine On
RewriteCond %{HTTP_HOST} burrowpress.com$ [NC]
RewriteCond %{REQUEST_URI} !^/burrowpress/.*$
RewriteRule ^(.*)$ /burrowpress/$1
Right now permalinks are working in WordPress and the redirect works but images have to be direct links to waringis.com/burrowpress/images/ instead of burrowpress.com/images/ - Any help is much appreciated...
You need to swap your code blocks around. The [L] flag on the WordPress rules are stopping execution of the file at that line in their code since your special path would "pass" the WordPress REWRITE_COND statements:
RewriteEngine On
RewriteCond %{HTTP_HOST} burrowpress.com$ [NC]
RewriteCond %{REQUEST_URI} !^/burrowpress/.*$
RewriteRule ^(.*)$ /burrowpress/$1 [L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
You don't need two RewriteEngine On statements, but since WordPress is able to rewrite your .htaccess file (depending on how you have it setup) you might want to leave it. If you are updating your file manually, you can remove the second RewriteEngine on directive.
The important part is that I moved your special rules ahead of wordpress.
I'm not a .htaccess expert but i would say that you don't need to include RewriteEngine On twice that you can put the redirect code in the if statement. So you want to redirect to the subdomain but not have your images be kept in the subdomain is this correct?

Resources