Skip to content

[Bug] Rewrite rules are not specific enough, instead capturing adjacent naming #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task
possumbilities opened this issue Mar 27, 2025 · 1 comment · Fixed by #91
Closed
1 task
Assignees
Labels
💻 aspect: code Concerns the software code in the repository 🛠 goal: fix Bug fix 🟧 priority: high Stalls work on the project or its dependents 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work

Comments

@possumbilities
Copy link
Contributor

possumbilities commented Mar 27, 2025

Description

/config/web-sites-available/000-default.conf : lines 156-162 (assuming)

  RewriteCond %{REQUEST_URI} !^/rdf
  RewriteCond %{REQUEST_URI} !^/publicdomain
  RewriteCond %{REQUEST_URI} !^/platform/toolkit
  RewriteCond %{REQUEST_URI} !^/licen[cs]es
  RewriteCond %{REQUEST_URI} !^/faq
  RewriteCond %{REQUEST_URI} !^/choose
  RewriteCond %{REQUEST_URI} !^/cc-legal-tools

These rewrite rules are too generic. If someone creates a page within WordPress labelled faq-cert-program or faq_groups or choose-our-campaign or chooseusnow it throws a white page with the following error:

Not Found
The requested URL was not found on this server.

Not only is this incorrect behavior, it also doesn't allow WP to handle the 404 condition, sending a user to a stripped down page, absent the theme.

Reproduction

  1. Visit any URL prepended by the above plus additional text. For example https://creativecommons.org/choose-our-campaign
  2. See error.

Expectation

These conditions should be more exacting matches. The condition should occur when /faq is requested, but NOT when /faq-cert-course is. The same limited behavior should occur for all these conditions.

Example expected behaviors to model from:

  • If a user navigates to /faq the rewrite/redirect SHOULD occur.
  • if a user navigates to /faq/thing the rewrite/redirect SHOULD occur.
  • if a user navigates to /faq-item-here the rewrite/redirect should NOT occur.
  • if a user navigates to /choose-use-this-holiday-season the rewrite/redirect should NOT occur.
  • if a user navigates to /publicdomainday the rewrite/redirect should NOT occur.

These are not all encompassing, but hopefully provide a good framework to start from.

Screenshots

Image

Additional context

I believe the correct direction would be this pattern of change, for all of the above items:

RewriteCond %{REQUEST_URI} !^/faqRewriteCond %{REQUEST_URI} !^/faq$

However, if the aim is to also redirect any sub-routes of /faq/ further changes may be required.

❗❗ Note: This is a blocking behavior within this repository as well as index__stage and index__prod for the new FAQs behavior within vocabulary-theme, as well as a possible collision for the new Cert site migration, which has its own FAQ page.

Resolution

  • I would be interested in resolving this bug.
@possumbilities possumbilities added 💻 aspect: code Concerns the software code in the repository 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work 🛠 goal: fix Bug fix 🟧 priority: high Stalls work on the project or its dependents labels Mar 27, 2025
@possumbilities possumbilities added 🏁 status: ready for work Ready for work and removed 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work labels Mar 27, 2025
@possumbilities possumbilities moved this to Triage in TimidRobot Mar 27, 2025
@possumbilities possumbilities moved this to Triage in Shafiya-Heena Mar 27, 2025
@possumbilities possumbilities added 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work and removed 🏁 status: ready for work Ready for work labels Mar 27, 2025
@Shafiya-Heena Shafiya-Heena moved this from Triage to In progress in TimidRobot Mar 28, 2025
@Shafiya-Heena Shafiya-Heena moved this from Triage to In progress in Shafiya-Heena Mar 28, 2025
@TimidRobot
Copy link
Member

TimidRobot commented Mar 31, 2025

Reproducible tests

Prep

In local dev WordPress Admin:

  1. Create and publish faq-cert-program page in WordPress
  2. Create and publish choose-our-campaign page in WordPress
  3. Create and publish publicdomainday page in WordPress

FAQ redirect

  • Description:
    • If a user navigates to /faq the rewrite/redirect SHOULD occur.
  • Command:
    http --all --follow --headers 'http://localhost:8080/faq'
    
  • Output (✅ redirect and non-WordPress 200 OK):
    HTTP/1.1 301 Moved Permanently
    Connection: Keep-Alive
    Content-Length: 311
    Content-Type: text/html; charset=iso-8859-1
    Date: Mon, 31 Mar 2025 05:45:33 GMT
    Keep-Alive: timeout=5, max=100
    Location: http://localhost:8080/faq/
    Server: Apache/2.4.59 (Debian)
    
    HTTP/1.1 200 OK
    Accept-Ranges: bytes
    Connection: Keep-Alive
    Content-Encoding: gzip
    Content-Type: text/html
    Date: Mon, 31 Mar 2025 05:45:33 GMT
    ETag: "38039-62907b0195ec6-gzip"
    Keep-Alive: timeout=5, max=99
    Last-Modified: Thu, 12 Dec 2024 00:20:56 GMT
    Server: Apache/2.4.59 (Debian)
    Transfer-Encoding: chunked
    Vary: Accept-Encoding
    

FAQ link

  • Description:
    • if a user navigates to /faq/thing the rewrite/redirect SHOULD occur.
  • Command:
    http --all --follow --headers 'http://localhost:8080/faq/#for-licensors'
    
  • Output (✅ non-WordPress 200 OK):
    HTTP/1.1 200 OK
    Accept-Ranges: bytes
    Connection: Keep-Alive
    Content-Encoding: gzip
    Content-Type: text/html
    Date: Mon, 31 Mar 2025 05:47:39 GMT
    ETag: "38039-62907b0195ec6-gzip"
    Keep-Alive: timeout=5, max=100
    Last-Modified: Thu, 12 Dec 2024 00:20:56 GMT
    Server: Apache/2.4.59 (Debian)
    Transfer-Encoding: chunked
    Vary: Accept-Encoding
    

WordPress FAQ-other

  • Description:
    • if a user navigates to /faq-item-here the rewrite/redirect should NOT occur.
  • Command:
    http --all --follow --headers 'http://localhost:8080/faq-cert-program'
    
  • Output (❌ non-WordPress 404 Not Found):
    HTTP/1.1 404 Not Found
    Connection: Keep-Alive
    Content-Length: 273
    Content-Type: text/html; charset=iso-8859-1
    Date: Mon, 31 Mar 2025 05:54:58 GMT
    Keep-Alive: timeout=5, max=100
    Server: Apache/2.4.59 (Debian)
    

WordPress choose-other

  • Description:
    • if a user navigates to /choose-use-this-holiday-season the rewrite/redirect should NOT occur.
  • Command:
    http --all --follow --headers 'http://localhost:8080/choose-our-campaign'
    
  • Output (❌ non-WordPress 404 Not Found):
    HTTP/1.1 404 Not Found
    Connection: Keep-Alive
    Content-Length: 273
    Content-Type: text/html; charset=iso-8859-1
    Date: Mon, 31 Mar 2025 06:00:27 GMT
    Keep-Alive: timeout=5, max=100
    Server: Apache/2.4.59 (Debian)
    

WordPress publicdomain-other

  • Description:
    • if a user navigates to /publicdomainday the rewrite/redirect should NOT occur.
  • Command:
    http --all --follow --headers 'http://localhost:8080/publicdomainday'
    
  • Output (❌ non-WordPress 404 Not Found):
    HTTP/1.1 404 Not Found
    Connection: Keep-Alive
    Content-Length: 273
    Content-Type: text/html; charset=iso-8859-1
    Date: Mon, 31 Mar 2025 06:01:24 GMT
    Keep-Alive: timeout=5, max=100
    Server: Apache/2.4.59 (Debian)
    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💻 aspect: code Concerns the software code in the repository 🛠 goal: fix Bug fix 🟧 priority: high Stalls work on the project or its dependents 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work
Projects
Archived in project
Archived in project
3 participants