.htaccess redirect to other page with link info

Posted on 2013-06-15
Last Modified: 2013-06-17
I want to redirect pages that are not found to a redirect_page.php using .htaccess but I want to also process the link information.

For example if I have a link to the following pages that don't exist or
how do I pass the '/213' & '/page=454' part to my redirect_page.php page?

ErrorDocument 404
Question by:sabecs
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 50

Accepted Solution

Steve Bink earned 500 total points
ID: 39250558
You'll have to use a rewrite to do this.  Something like:

RewriteRule (.+) /redirect_page.php?uri=$1 [QSA]

Open in new window


Author Comment

ID: 39250704
Thanks routine for your help, but when I tried your code I receive an Internal Server Error?
LVL 50

Expert Comment

by:Steve Bink
ID: 39251491
Make sure you have mod_rewrite enabled.  Are you using any other rules?
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.


Author Comment

ID: 39252109
Thanks  routinet, this is what I have so in my .htaccess.

#SetEnv PHPRC /home/mywebsite/public_html
Options +FollowSymLinks
Options +Indexes
RewriteEngine On

RewriteCond %{REQUEST_URI} Details
RewriteRule ^([^/]*)/([^/]*)/([^/]*)\.html$ /index.php?page=$1&id=$2&new_page_title=$3 [L]
RewriteRule ([0-9]+)(.*)\.html$ index.php?page_id=$1 

RedirectMatch permanent ^/show/?$
RedirectMatch permanent ^/showme/?$

RewriteRule (.+) /redirect_page.php?uri=$1 [QSA]

Open in new window

LVL 50

Expert Comment

by:Steve Bink
ID: 39253773
I don't see anything obvious there.  Try turning on your RewriteLog...perhaps mod_rewrite can provide some feedback about the application of these rules.

Note that you have to turn on the log in your server conf files, not .htaccess.

Author Closing Comment

ID: 39254903
Thanks routine, seems to be working now, not sure what I missed...

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how do I get rid of "Multiple Choices The document name you requested" 3 340
PHP Error Settings 12 87
htaccess file 3 98
PHP: Insert Data into MySQL 5 68
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
Introduction This article is intended for those who are new to PHP error handling (  It addresses one of the most common problems that plague beginning PHP develop…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit If you want to manage em…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…
Suggested Courses

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question