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 574293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:48:54+00:00 2026-05-13T13:48:54+00:00

I would like to add a rewrite Condition in my htaccess that would be

  • 0

I would like to add a rewrite Condition in my htaccess that would be true if calling a php file returns “true” or false otherwise. I’ am using the -U switch in my RewriteCond to run a subrequest and if the condition is not satisfied, the PHP script returns a 404 error, which triggers the rewriteCond.

My goal is to run a URL shortening service in parallel with a PHP website.

Here is my current .htaccess

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond /smallurl/%{REQUEST_URI} !-U
RewriteRule (.*) index.php/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) smallurl/$1 [L]

What is the best practice to achieve something like this? Recomendations, things I should be aware of? Is there a way to avoid the subrequest, or at least speed it up?

Thank you

  • 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-13T13:48:54+00:00Added an answer on May 13, 2026 at 1:48 pm

    You can use a RewriteMap to pass the REQUEST_URI to a php file, which returns the result – I think this would work with RewriteCond, although you might find it works better as a standard RewriteRule

    The spec is at http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html#RewriteMap

    Basically, your php file needs to read from php://stdin and output the result to stdout

    Sorry I can’t be more helpful, it’s not something I’ve done in a long, long time!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this .htaccess that I've been using to rewrite URLs like these: www.example.com/index.php?page=brand
I have an application in PHP (private CMS) that I would like to rewrite
I would like to create rewrite rules in my .htaccess file to do the
I currently have a .htaccess file that rewrites dyhamb.com/episode.php?episode=1 as dyhamb.com/1 . I would
I would like to add roots to a VirtualTreeView http://www.delphi-gems.com/index.php/controls/virtual-treeview with a thread like
I would like to add a hash into an array using Ruby version 1.8.7:
I would like create URL rewrite rule that will set default document for my
Possible Duplicate: Redirect *.htm to *.php htaccess rewrite if redirected file exists I set
I would like to rewrite: http://url.com/app_name/action.do to http://url.com/context/action.do?value=1 My question is how to add
I am using php CodeIgniter and have the following rewrite rule in my .htaccess

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.