I’ve having trouble working out the correct entries to put into my .htaccess file.
What I’m trying to do is:
1) Allow all requests for certain file types to work correctly. (ie jpg|gif|png|css|js|ico)
This will allow all files included with web pages to work correctly.
2) All requests to “login” to be redirected to login page, with parameters. eg
/login
/Login (different case)
/login/
/login/index.py
/login/scipt/index.py
/login?id=1&attr=foobar
/login/index.py?mode=1&attr=foobar?name=Billy
/login/scipt/index.py?index=999
/login/?anotherparam=value (basically, the parameter list can vary)
Should ALL redirect to:
/login.py
And those with GET parameters, should redirect to:
/login.py?(copied list of parameters without these brackets)
3) Everything else should be redirected to root (ie ‘/’) keeping any parameters. eg
/NotAPage.html
/NotAFolder/
/NotAFolder/NotAPage.html
/NotAPage.html?v=1&k=2
/NotAFolder/?a=2
/NotAFolder/NotAPage.html?a=99&b=55&c=99 (again, the parameter list can vary)
Should ALL redirect to:
/
And those with GET parameters, should redirect to:
/?(copied list of parameters without these brackets)
So far, I’ve gotten this far:
#Make PY (Python) files executable outside of CGI-BIN
AddHandler cgi-script .py
Options +ExecCGI
# Turn on URL rewriting engine
RewriteEngine On
# Allow these file types to pass through untouched
RewriteCond %{REQUEST_URI} !\.(jpg|gif|png|css|js|ico)$
# Redirect all other requests to index.py
RewriteRule (.*) index.py [L,PT]
Which, I believe, is getting everything (except the list of suffixes) to redirect to index.py, with parameters, but it’s not doing everything I need yet.
Can anyone point me in the right direction please?
The
PTflag implies theLflag: rewriting will be stopped in order to pass the request to the next phase of processing.Note that the
PTflag is implied in per-directory contexts such as<Directory>sections or in.htaccessfiles. The only way to circumvent that is to rewrite to-.