Skip to content
Snippets Groups Projects
Verified Commit 7681ac2c authored by Owen Graham's avatar Owen Graham
Browse files

Set up redirect to new CGI script name

parent d002d7d3
No related branches found
No related tags found
No related merge requests found
Options +ExecCGI Options +ExecCGI
AddHandler cgi-script .py
<FilesMatch "^-$"> <FilesMatch "^-$">
SetHandler cgi-script SetHandler cgi-script
</FilesMatch> </FilesMatch>
......
#!/usr/bin/env python3
"""Redirect to the new CGI script name, "-"."""
import os
from pathlib import PurePosixPath
request_script = PurePosixPath(os.getenv('SCRIPT_NAME'))
request_uri = PurePosixPath(os.getenv('REQUEST_URI'))
relative = request_uri.relative_to(request_script)
target_script = request_script.with_name('-')
target = target_script / relative
print('Status: 308 Permanent Redirect')
print(f'Location: {target}')
print()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment