Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to set HTTP redirect code via new variable POLR_REDIRECT_CODE #602

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion app/Http/Controllers/LinkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,13 @@ public function performRedirect(Request $request, $short_url, $secret_key=false)
// Record advanced analytics if option is enabled
ClickHelper::recordClick($link, $request);
}
if (env('POLR_REDIRECT_CODE')) {
$redirect_code = env('POLR_REDIRECT_CODE');
} else {
$redirect_code = 301;
}
// Redirect to final destination
return redirect()->to($long_url, 301);
return redirect()->to($long_url, $redirect_code);
}

}
3 changes: 3 additions & 0 deletions resources/views/env.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
# Set to true to enable password recovery
SETTING_PASSWORD_RECOV={{$ST_PASSWORD_RECOV}}

# Set to change redirect code to e.g. 302 or 301
POLR_REDIRECT_CODE={{$POLR_REDIRECT_CODE}}

# Set to true to generate API keys for each user on registration
SETTING_AUTO_API={{$ST_AUTO_API}}

Expand Down
2 changes: 2 additions & 0 deletions tests/test_env
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ SETTING_SHORTEN_PERMISSION=false
SETTING_INDEX_REDIRECT=
SETTING_PASSWORD_RECOV=false

POLR_REDIRECT_CODE=301

APP_LOCALE=en
APP_FALLBACK_LOCALE=en

Expand Down