Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6651393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:00:22+00:00 2026-05-26T01:00:22+00:00

I wrote a regex for a rewrite rule that includes a negative lookahead to

  • 0

I wrote a regex for a rewrite rule that includes a negative lookahead to replace the rewriteCond line, because WordPress only accepts two values: pattern -> substitution.

It should find findme.html _here, regardless of where it’s requested to be:
mydomain.com/_here/findme.html
e.g.

(Sorry, I can’t modify the swf which will request findme.html in the wrong places)

So, given findme.html could be requested to be in, e.g.:

mydomain.com/findme.html
mydomain.com/directory/findme.html
mydomain.com/directory/findme.html?someparam=3

The rewrite should make them all

mydomain.com/_here/findme.html

So, I made a rewrite rule that WordPress will accept me as follow

Options +FollowSymlinks
RewriteEngine On
RewriteRule ^.*(?!_here)/*findme\.html$ /_here/findme.html [R=301,L]

So it only matches URLs which doesn’t contain “_here” in it, to prevent extra rewriting or a loop.

The problem is IT DOES loop.

What did I miss?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:00:23+00:00Added an answer on May 26, 2026 at 1:00 am

    It looks to me like you want to move the .* that is before (?!_here) to after it because (?!_here) is a negative lookahead, so it check that the text _here does not come after it. What your regular expression is actually checking is whether your url starts with some character sequence that is not followed by _here, and _here is a character sequence not followed by _here. Then your rule becomes

    RewriteRule ^(?!_here).*/*findme\.html$ /_here/findme.html [R=301,L]
    

    Also, it looks like your pattern will exclude paths with subdirectories such as

    mydomain.com/directory/subdirectory/findme.html
    

    If you also want to include those, the pattern should be

    RewriteRule ^(?!_here)(.*/)*findme\.html$ /_here/findme.html [R=301,L]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a regex function that will identify and replace a single
I currently have the working Mod Rewrite Regex: RewriteEngine On RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule
I just wrote a regex for use with the php function preg_match that contains
I wrote this regex with the idea that it will match any string in
I wrote a regex that validates an input string. It must have a minimum
I wrote a regex to fetch string from HTML, but it seems the multiline
I want to write a regex that matches if a string contains XYZ but
How can I write a regex which will replace any file name, with it's
I'm trying to write a regex that will parse out the directory and filename
I'm trying to write a regex that will match everything BUT an apostrophe that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.