How may I perform a rule if the URL is NOT matching the path "forums"?
For example:
RewriteCond IF URL IS NOT forums RewriteRule !\.(js|gif|css|jpg|png)$ %{DOCUMENT_ROOT}/index.php [L]
RewriteRule defines a particular rule. The first string of characters after RewriteRule defines what the original URL looks like. There's a more detailed explanation of the special characters at the end of this article. The second string after RewriteRule defines the new URL.
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/.
A rewrite rule can be invoked in httpd. conf or in . htaccess . The path generated by a rewrite rule can include a query string, or can lead to internal sub-processing, external request redirection, or internal proxy throughput.
Apache's RewriteCond
as well as the RewriteRule
directive support the exclamation mark to specify a non-matching pattern:
You can prefix the pattern string with a '!' character (exclamation mark) to specify a non-matching pattern.
This should work:
RewriteCond %{REQUEST_URI} !^/forums.* RewriteRule !\.(js|gif|css|jpg|png)$ /index.php [L]
--> redirect all requests not beginning with forums and not ending with the listed suffices to index.php
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