PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, January 27, 2022

[FIXED] Redirect all URL calls to a particular php file

 January 27, 2022     .htaccess, mod-rewrite, php, regex     No comments   

Issue

Any http request (e.g. to pdf) should be redirected to validate.php so if you call an URL (e.g. http:...../whatever/whatever/1.pdf), htaccess should execute validate.php instead.

I went through many examples on web and stackoveflow, no luck yet. Since most work fine for many people, I guess there must be something wrong with my server.

How can I solve this issue?

Thanks

Note: htaccess and validate.php files are stored in the root.

  • .htaccess - How to redirect all urls to url.php except index.php
  • htaccess Redirect All Requests to Index.php Script
  • How to redirect all requests to a file, except images using Apache?
  • Redirect All Requests To Index.php Using .htaccess

And many more.


Solution

put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteRule \.pdf$ /validate.php [L,NC]


Answered By - anubhava
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing