Ignore existing files/folder with.htaccess

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Ignore existing files/folder with.htaccess

Post by alex.barylski »

I have the following which works:

Code: Select all

RewriteEngine on
RewriteBase /
 
RewriteCond %{HTTP_HOST} ^pcspectra.com [NC]
RewriteRule ^(.*)$ http://www.pcspectra.com/$1 [L,R=301]
 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,NC,L]
The last 3 lines are what I probalby want to comment out, but I think this would mean I would have to handle image requests and everything which I do not want to do. I have an index.php in a root directory and some custom scripts in a sub-directory which are invoked like:

Code: Select all

scripts/add_contact.php
scripts/add_contact.php?dept=3&owner=4
I would like to intercept these requests and perform custom processing and then continue letting each handle the request from there on in. Do I have to emulate an HTTP request forward or something internally within my own index.php located in the root directory?

Is there an easy way to perform this request, basically just catching the request (doing my thing) then emulating/copying the exact request by forwarding the HTTP request exactly as it was intercepted???

Even if I had to execute an binary or something so I don't have to implement an HTTP client inside my index.php that would be awesome...

Any ideas?

Cheers,
Alex
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Ignore existing files/folder with.htaccess

Post by alex.barylski »

Also, what would I add to the .htaccess file in order to continue normally for everything other than *.php extensions and quite possibly only a few limited scripts or queries to boot?

EDIT | Please do not confuse HTTP request forward with a forward VS redirect at the controller level. I need to literally forward an entire HTTP request onto a third party script which when invoked will have no clue it's been executed by a emulated server or whatever solution I decide on.

Cheers,
Alex
Post Reply