I'd like to make it so that any request for any file or page on my website gets directed to a single file: site_down.php
I know how to do this with apache rewrites but can't find a specific example for Zeus
match URL into $ with ^
if matched then
set URL = /site_down.php
endif
Related
Note: I couldn't find any similar question. Please let me know if duplicate question exists. I don't want to put duplicate question intentionally.
I have directory structure longer which I don't want users to find out as well as I want download file URL to be fancy.
My directory structure is
Actual File Path = ./my_dir/files/upload/user_images/user_file.pdf
My Domain is having ./my_die/ as Document Root so example.com will serve contents of ./my_dir/
To download file I have http://example.com/files/upload/user_files/user_file.pdf
Which I want to convert to
http://example.com/user/uploads/user_file.pdf
So I need MOD Rewrite Rule to convert as following:
http://example.com/files/upload/user_files/user_file.pdf to http://example.com/user/uploads/user_file.pdf
You may use this rewrite rule in your site root .htaccess:
RewriteEngine On
RewriteRule ^user/uploads/(.+)$ files/upload/user_files/$1 [L,NC]
I try to make specific rewrite rules by .htaccess but i need help, its doesn't work.
This is my url :
http://mywebsite.net/aaa-bbbb/cccc
aaa = dynamic parameter ( [a-z] )
bbb = dynamic parameter ( [a-z] )
cccc = dynamic parameter but optionnal ( [a-z] )
And i want rewrite user to this url :
http://mywebsite.net/mydir/ccc?x=aaa&y=bbbb**
url still will http://mywebsite.net/aaa-bbbb/cccc on tabbar
i try this
RewriteRule ^([a-z]+)-([a-z]+)/([a-z]+)$ mydir/$3 [L]
but it doesn't work
thx !
To rewrite a request to
http://mywebsite.net/aaa-bbbb/cccc
internally to
/mydir/ccc?x=aaa&y=bbbb
you need such a rewrite rule:
RewriteEngine on
RewriteRule ^([a-z]+)-([a-z]+)/([a-z]+)$ /mydir/$3?x=$1&y=$2 [L]
Note: the above rule has the syntax to be used inside the http servers host configuration. If you really want to use a .htaccess style file instead you need to use a slightly modified syntax, since those files work on relative paths:
RewriteEngine on
RewriteRule ^([a-z]+)-([a-z]+)/([a-z]+)$ mydir/$3?x=$1&y=$2 [L]
You can spot the missing / in the rewrite goal. The .htaccess style file has to reside inside the folder holding the mydir folder for this to work. Also the interpretation of such files has to be enabled at all in the http server configuration for.
A general note: .htaccess style files are notoriously error prone, hard to debug and they really slow down the http server for nothing. They are only offered as a last option for those not having access to the http servers host configuration. So for example for cheat shared hosting providers. In general you should always prefer to place such rules inside the host configuration itself.
I'm using Cheyenne v0.9 and would like to serve static HTML files as text/html, but I don't want the URLs to contain the .html extension. Is there a way to do this without using CGI or some other dynamic processor?
For example:
/path/to/example.org/web-root/about.html
To be reached using:
http://example.org/about
The Apache equivalent 'ReWrite' would be something like:
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule !.*\.html$ %{REQUEST_FILENAME}.html [L]
you can build a very simple mod which does this...
save the following as cheyenne/mods/mod-auto-ext.r
REBOL []
install-HTTPd-extension [
name: 'mod-auto-ext
order: [url-translate first]
auto-ext: '.html ; use whatever automatic extension you want!
url-translate: func [req /local cfg domain ext][
unless req/in/ext [
req/in/ext: auto-ext
append req/in/target req/in/ext
]
; allow other mods to play with url (changing target path for example)
return none
]
]
then add your module within your httpd.cfg like so :
modules [
auto-ext ;<----- put it as first item in list, whatever mods you are using.
userdir
internal
extapp
static
upload
expire
action
;fastcgi
rsp
ssi
alias
socket
]
restart cheyenne and voila!
If you look at the source for other mods, you can VERY easily setup a keyword for use in the httpd.cfg file in order to setup the auto-ext variable within the mod.
Looking for a little help with Zeus Rewrite.Script for multiple directories - I have a working script that operates in I place Wordpress in a sub-directory - however, If I want to run another Wordpress installation in another directory I can't get the rewrite to work with this too. Any help would be greatly appreciated!
My rewrite for 1 directory;-
#Zeus webserver version of basic Wordpress mod_rewrite rules
map path into SCRATCH:path from %{URL}
look for file at %{SCRATCH:path}
if exists then goto END
look for dir at %{SCRATCH:path}
if exists then goto END
##### FIX FOR LOGIN/FORGOTTEN PASSWORD/ADMIN ETC #####
match URL into $ with ^/site1/wp-.*$
if matched then goto END
##### FIX TO ALLOW SEARCH TO WORK #####
match URL into $ with ^/oxford-walking-tours/(.*)
set URL = /site1/index.php/$1
So site1 in the first directory - can anyone suggest how I can make this work for site2 as well?
Thanks
The script below is one that may help all ZEUS server redirecting
It ignores the folder called myfolder (replace this with one you want to exclude from any redirect, you can still get to it.)
And the rest of the file redirects to the .com version of the website in www form (rule2) and without www (rule1).
Save the file as rewrite.script and upload to root directory of server.
#ignore anything to do with myfolder
match URL into $ with ^/myfolder(\/)?.*
if matched then goto END
RULE_1_START:
match IN:Host into $ with ^mywebsite\.net$
if matched then
match URL into $ with ^/(.*)$
if matched then
set OUT:Location = http://www.mywebsite.com/$1
set OUT:Content-Type = text/html
set RESPONSE = 301
set BODY = Moved
endif
endif
RULE_1_END:
RULE_2_START:
match IN:Host into $ with ^www.\mywebsite\.net$
if matched then
match URL into $ with ^/(.*)$
if matched then
set OUT:Location = http://www.mywebsite.com/$1
set OUT:Content-Type = text/html
set RESPONSE = 301
set BODY = Moved
endif
endif
RULE_2_END:
I wound up with a bunch of backlinks to my site that have the correct URL, except there was an accidental trailing space so the links came out with a trailing %20, which causes a page not found error.
I tried variations on this:
RewriteRule ^/%20 /
but it's not working.
Is a RewriteCond statement also needed?
Please note this is an IIS 6 server, and these are Wordpress pages that I'm linking to.
Somebody please tell he the secret code to get rid of a %20 at the end of a URL.
Thanks!
You may permanently redirect all concerned urls having a trailing %20 to the same url without the trailing %20 by using the following rule:
If you use UrlDecoding Off in your iirf.ini, use:
RedirectRule (.*)%20$ $1 [R=301]
Otherwise, IIRF automatically decodes the URL for you before trying to apply the rules. You can therefore use:
RedirectRule (.*)\s$ $1 [R=301]
In order to test this using testdriver.exe:
Put the above rule in a file called iirf.ini.
Create a file called SampleUrls.txt containing some test URLs, for example:
/ NO REWRITE
/%20 REDIRECT 301 /
/article NO REWRITE
/article%20 REDIRECT 301 /article
Call testdriver with a command similar to %iirfpath%\testdriver.exe -d .
Please note: testdriver does not decode URLs.
You should get an output similar to the following (I removed some newlines):
TestDriver: linked with 'Ionic ISAPI Rewriting Filter (IIRF) 2.1.1.28 x64 RELEASE'.
TestDriver: The IIRF library was built on 'Aug 8 2011 02:26:29'
Processing URLs...(.\SampleUrls.txt)
***
Retrieving server variable that is not supported by TestDriver (SCRIPT_NAME)
NO REWRITE '/' ==> --
OK
***
Retrieving server variable that is not supported by TestDriver (SCRIPT_NAME)
REDIRECT 301 '/%20' ==> '/'
OK
***
Retrieving server variable that is not supported by TestDriver (SCRIPT_NAME)
NO REWRITE '/article' ==> --
OK
***
Retrieving server variable that is not supported by TestDriver (SCRIPT_NAME)
REDIRECT 301 '/article%20' ==> '/article'
OK
0 Errors in 4 Total Trials