BonJon
BonJon

Reputation: 799

How to redirect to a file

I have a question regarding the rewrite rule in my app. One of my JS files that is built by other team request a file that is not in our domain. I am trying to set a rewrite rule to make it redirect to another page in my .htaccess. file when the file request happens.

For example: My current console log shows

GET http://example.com/file.object?_=1234 404 (Not Found)

I want to redirect it to

http://example.com/processLink to process the correct file. 

My rewrite rule

RewriteCond %{REQUEST_URI} /file.object
RewriteRule ^.*$ /processLink/ [R=302]

It doesn't work. I am a bit rusty on the rewrite rules. Can anyone help me about it? Thanks so much!

Upvotes: 1

Views: 72

Answers (2)

anubhava
anubhava

Reputation: 785651

This rule should work for you:

RewriteRule ^file\.object$ /processLink? [R=302,NC,L]

Upvotes: 1

Ding
Ding

Reputation: 3085

I would change it to

RewriteEngine On
RewriteRule ^/file\.object /processLink [R=302]

Upvotes: 1

Related Questions