4

RewriteRule / RewriteCond help - matches anything except a directory

 2 years ago
source link: https://www.codesd.com/item/rewriterule-rewritecond-help-matches-anything-except-a-directory.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

RewriteRule / RewriteCond help - matches anything except a directory

advertisements

Currently, I have the rule

RewriteRule ^([A-Za-z0-9-/]+)$ myFile.php?myId=$1

I want to be able to access a folder and its files (lets just say it's called example), and the index.php of it. However, using the rule

RewriteRule ^example$ example/index.php [L]

it instead matches the first rule. It is the first rule of the file, though.


After your rewrite rules are executed, the example URL is rewritten to example/index.php, and then re-enters the rewrite process (the [L] flag does not prevent that). Then, your other rewrite rule matches.

So you must add an exception for example/index.php. For example:

RewriteRule ^example/index.php$ - [L]

which terminates the second rewrite run. Make sure to insert it above your other rule.

Related Articles

How to match anything except a particular pattern after / before a specific string constant

ATS(inline, const, unused) /* Variadic Macro */ OTS(inline, const, unused) I'm trying to match inline, const, unused keywords only in ATS macro. i tried ATS([^,]*) but it only matches inline keyword. Edit: I need to change the color of all ATS parame

How to match the exception with the double character with the regular expression of Python?

Got this string and regex findall: txt = """ dx d_2,222.22 ,, dy h..{3,333.33} ,, dz b#(1,111.11) ,, dx-ay relative 4,444.44 ,, """ for n in re.findall( r'([-\w]+){1}\W+([^,{2}]+)\s+,,\W+', txt ) : axis, value = n print "

Javascript Regex matches everything except double space and then replaces

I need a regex that will match anything except white spaces or only words in between double spaces. Like : let's assume the underscores where equal to spaces just for example. foo_bar__The_Quick_Dog__is_addicted_to___jumping___ Then replace the space

Define a regular JavaScript expression that matches anything but a particular string

Ok, I'm feeling pretty thick right now. Basically, I want to define a JavaScript regular expression that will match anything except precisely a particular string. So say I have the string "dog" or "cat" I want a single standalone regul

Is there a way to match everything except a constant string using Go.Regexp?

I have found many similar questions that do not work with the Go regex syntax. The string that I am attempting to match against is in the form of anything/anything/somestring. With the pattern \/.*\/.*\/(.*), I will match somestring, but I am trying

Regex - matches everything except a specific string

I need a regex (will be used in ZF2 routing, I believe it uses the preg_match of php) that matches anything except a specific string. For example: I need to match anything except "red", "green" or "blue". I currently have the

PHP preg_match: matches anything but the string

I need to be able to extract segments of a full file path and name to insert into a data base. To do this I am using preg_match in PHP. I am also giving each segment a name from within the pattern so that the array of matches is an associative one. H

regex is equivalent to something exactly but does not match anything else

my regex query below does an exact match of a word say Bob or Bill for example var regExp = new RegExp("^" + inputVal + "$", 'i'); what i want it to do is match anything exactly (Bob or Bill Etc) but not match Fred so match anything ex

RewriteRule with greedy matches trying to redirect the root to a page, and rewrite all other queries on https

I am trying to work with apache2 rewrite to perform two functions rewrite (or redirect) / (root) requests to a specific page: /index all requests (including / and /index) on port 80, are rewritten to HTTPS Here is my failed attempt RewriteEngine On R

Match everything except emails with this Regex pattern

So, I have rows of text with plenty unnecessary information in them (in a google sheet). I would like to match everything except the EMAIL for which I'm using the following regex: [a-zA-Z0-9_.+-]+@(?:[a-zA-Z0-9-]+\.)+(?!png|jpg|gif)[a-zA-Z0-9-]+ If I

Regex matches all except character groups

I'm trying to match the following strings: PHANTOGRAM • CUT / COPY • AB$SID 3 • FITZ & THE TANTRUMS PHANTOGRAM,CUT / COPY,AB$SID 3,FITZ & THE TANTRUMS PHANTOGRAM CUT / COPY AB$SID 3 FITZ & THE TANTRUMS So, basically regex that matches anything

Matches everything except a specific model in JavaScript

After much searching I am still stumped. How do I match everything in a string except what matches a given pattern. I have found solutions for negating specific words or character sets using the ^ or negative look ahead, but I need a solution to nega

Matches everything except for the specified strings

I know that the following regex will match "red", "green", or "blue". red|green|blue Is there a straightforward way of making it match everything except several specified strings?If you want to make sure that the string is ne

Using MATLAB for anything except mathematics

I was reading about MATLAB and I'm so much curious on it. But I have some questions: Can I use it for anything except maths? Can you list some examples with links to the full code? I know that the name of the language is very subjective, but I want t

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK