Welcome to WebmasterWorld Guest from 54.167.155.147

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

need to bypass wordpress htaccess for scripts in subdirectory

tried everything I can think of

   
9:33 pm on Apr 25, 2013 (gmt 0)

5+ Year Member



I need an htaccess guru

trying to bypass wordpress htaccess for scripts within a subdirectory (symbolic link off wordpress root)

I have wordpress installed on hostgator shared
public_html/onedomain.com
and a redirect script in
public_html/redirect

there's a symbolic link
public_html/onedomain.com/redirect

that works just fine until the wordpress permalink entries break it

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
</IfModule>


I've tried just about every variation of

RewriteRule redirect/(.*)$ - [L]
or
RewriteCond %{REQUEST_FILENAME} !-l
and
RewriteCond %{REQUEST_FILENAME} -l

I can think of and can't find a solution.
6:36 am on Apr 26, 2013 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



Never mind links and scripts and bypassing. In English: what are you physically trying to do?

What, if any, are your current RewriteOptions settings? Everything is off by default, but if you're on shared hosting your host may have something in the config file. This is worth checking, because mod_rewrite unlike almost everything else in Apache does not inherit by default. So putting a second set of rewrite directives in a subdirectory is often enough to kill any rewrites created in the main directory. (If this sounds confusing, it is.)
8:17 am on Apr 26, 2013 (gmt 0)

5+ Year Member



I'm trying to add a rule that says "if the request if for something in redirect let it go and ignore the rules that follow

like in the wordpress standard ruleset

RewriteBase /
RewriteRule ^index\.php$ - [L] #this rule says if the request if for index.php, deliver whatever index.php has
RewriteRule test for /something in my subdirectory - [L] #deliver what's in there
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
1:59 pm on Apr 27, 2013 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



instead of that RewriteRule you need a RewriteCond that excludes uri paths beginning with redirect.
9:28 pm on Apr 27, 2013 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



... and put this RewriteCond before the ones that check for -f and -d.

But if you don't want any further rewriting to happen, ever, to requests for the /redirect/ directory, you can perfectly well put it into the same rule that convers /index.php:

RewriteRule ^(redirect/|index\.php$) - [L]

Note position of slashes and anchors.
6:54 pm on Apr 28, 2013 (gmt 0)

5+ Year Member



I've tried just about everything I can think of, and all fails, it only works if I comment out all the WordPress rules.
RewriteRule ^(redirect/|index\.php$) - [L]
RewriteRule ^(/redirect/|index\.php$) - [L]
RewriteRule ^(redirect/.*|index\.php$) - [L]
RewriteRule ^(/redirect/.*|index\.php$) - [L]
9:00 pm on Apr 28, 2013 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



Note position of slashes and anchors.

You are either in htaccess, or not in htaccess. If it's shared hosting, it is definitely htaccess. If it's your own server, you know best. If you are not capturing and there is no closing anchor, a trailing .* is never necessary.

it only works if I comment out all the WordPress rules

Uh-oh. Half of the rules should always fail. Which half depends on where you are.

But "where you are" is the crucial question here. Not just what file, but where in file. Your RewriteRules need to be in the correct location relative to the rules that WordPress has put in place. Within each individual module, rules execute from top to bottom.

The rule you're currently trying out-- the one with two pipe-delimited options-- is intended to replace the existing rule that only names "index\.php$". If it's located anywhere else, it will have undesired consequences. Fancy way of saying "won't work".
11:13 pm on Apr 29, 2013 (gmt 0)

5+ Year Member



I'm in shared hostgator.
Is there a way to tell it "If redirect let redirect have it"?