.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 51

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 51

Expert Comment

by:Steve Bink
ID: 39251491
Make sure you have mod_rewrite enabled.  Are you using any other rules?
Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.


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 51

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

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…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor ( Top Charts is a view in which you can set seve…

691 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