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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:31:28+00:00 2026-05-26T10:31:28+00:00

I have an .htaccess file which calls a perl script if certain conditions are

  • 0

I have an .htaccess file which calls a perl script if certain conditions are met. The htaccess file looks like this:

Options +FollowSymlinks
ErrorDocument 404 /404.shtml

#check existence
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{PATH_INFO} (.*)

#redirect for codes
RewriteCond %{REQUEST_URI} !\.[css|jpg|gif|png]
RewriteRule ^(.*) /cgi-bin/normalized\.pl?code=$1 [R=301]

Codes get passed to the normalized.pl file such that if the URL requested was http://www.domain.com/code1, “code1” would be passed. If the code exists I can refer the user onwards to the correct page.

However, if the code doesn’t exist I wish for the user to be directed to my custom 404 page as defined in the htaccess file.

What seems to happen though is that the htaccess file sees the normalized pl as an existing file and I get a 200 response for the perl script. The perl script then returns a 404 header (as shown below) but it doesn’t show my custom 404 page – just a browser standard one.

print header(-status=>'404 Not Found',-type=>'text/html');

I suspect it’s because the .htaccess file has already been passed by the time the perl script runs.

How can I convince my browser to display the custom 404 page in this case? Would it be advisable/acceptable to force a 301 redirect from the perl script to the 404 page? But would that have any impact on search engines indexing the pages?

  • 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-26T10:31:28+00:00Added an answer on May 26, 2026 at 10:31 am

    The 404 header sent by your Perl script only tells the browser that the page was not found. There is no way for it to tell that to the web server, since the web server considers the request to be successful due to the fact that it found your Perl script.

    The only way for you to send your custom 404 page at that point would be to have the Perl script print the HTML for it after the 404 header.

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

Sidebar

Related Questions

I have a .htaccess file - looks something like this: RewriteEngine On <FilesMatch ^.*\.php.*$>
I have an htaccess file which maps http://www.myserver.com/home/ to http://www.myserver.com/index.php?section=home This part works fine.
I have the following in a .htaccess file redirect 301 /page.php http://domain.com/page Which works
I have an htaccess file that uses mod_rewrite to redirect /controller to /index.php?controller=%controller% Like
I have this .htaccess file in WordPress. It's located at /public_html/ (web root). I
So I have this .htaccess file in the /blog/ folder on my webserver and
I have a relatively complex .htaccess file to control page requests, this currently redirects
I have my .htaccess file setup like the following. It's a simple concept where
I have this little .htaccess file: RewriteEngine on RewriteRule ^(.*)$ urlroute.php?q=$1 [E=myvariable:'withthisvalue',B,QSA] To direct
I have an htaccess file which begins with the regular stuff: RewriteEngine on RewriteBase

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.