I'm trying to have the modrewrite rules skip the directory vip
. I've tried a number of things as you can see below, but to no avail.
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / #RewriteRule ^vip$ - [PT] RewriteRule ^vip/.$ - [PT] #RewriteCond %{REQUEST_URI} !/vip RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
How do I get modrewrite to entirely ignore the /vip/
directory so that all requests pass directly to the folder?
As points of clarity:
The <IfModule mod_rewrite. c>... </IfModule> block ensures that everything contained within that block is taken only into account if the mod_rewrite module is loaded. Otherwise you will either face a server error or all requests for URL rewriting will be ignored.
RewriteBase is a useful server directive available for Apache web server that allows you to easily update numerous rewrite rules at one go.
In order for Apache to understand rewrite rules, we first need to activate mod_rewrite . It's already installed, but it's disabled on a default Apache installation. Use the a2enmod command to enable the module: sudo a2enmod rewrite.
htaccess rewrite rules can be used to direct requests for one subdirectory to a different location, such as an alternative subdirectory or even the domain root. In this example, requests to http://mydomain.com/folder1/ will be automatically redirected to http://mydomain.com/folder2/.
Try putting this before any other rules.
RewriteRule ^vip - [L,NC]
It will match any URI beginning vip
.
-
means do nothing. L
means this should be last rule; ignore everything following. NC
means no-case (so "VIP" is also matched).Note that it matches anything beginning vip
. The expression ^vip$
would match vip
but not vip/
or vip/index.html
. The $
may have been your downfall. If you really want to do it right, you might want to go with ^vip(/|$)
so you don't match vip-page.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With