Zeus rewrite.script - multiple directories - url-rewriting

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:

Related

mod_rewrite rule for file to be downloaded from another directory

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]

rewrite rules with apache does not work

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.

Opencart How To] Multi-Store on Xampp Localhost

Is there someone that has set up the Opencart multistore in their computer locally threw Xampp that would know how to add the code properly. I have gone threw as many tutorial as Google and this forum has and can't seem to figure out how to properly place the code. A sample of how it should look when placed in the http.conf file will
really help .
The tutorials is asking me to edit the Apache Configuration file add “alias” for each sub store.
Alias /opcStore_1 "C:/xampp/htdocs/store"
Alias /opcStore_2 "C:/xampp/htdocs/store"
go to this path: C:\xampp\apache\conf\
Find httppd.conf file and open it
Search ”” section and add below code inside this section. ???
Alias /opcStore_1 "C:/xampp/htdocs/store"
Alias /opcStore_2 "C:/xampp/htdocs/store"
HOW DOES IT LOOKS WHEN THE CODE IS ADDED? Where inside do I add it and how it should look?
Because I tried placing it but only get error local URL. Thanks
Now, you have to restart Apache server from your XAMPP control panel. After restarting, you have to add sub stores in Opencart configuration.
OpenCart configuration for Multi stores.
Logon to your main store : C:/xampp/htdocs/store/admin
Goto: System > Settings and here you can add new stores.
When adding give stores urls: for First store give url: "http://localhost/opcStore_1/"
for 2nd Store give url: "http://localhost/opcStore_2/"
Will look like this, at the end i have added 5 sub store.
#
# Redirect: Allows you to tell clients about documents that used to
# exist in your server's namespace, but do not anymore. The client
# will make a new request for the document at its new location.
# Example:
# Redirect permanent /foo http:// localhost/bar
#
# Alias: Maps web paths into filesystem paths and is used to
# access content that does not live under the DocumentRoot.
# Example:
# Alias /webpath /full/filesystem/path
#
# If you include a trailing / on /webpath then the server will
# require it to be present in the URL. You will also likely
# need to provide a <Directory> section to allow access to
# the filesystem path.
#
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the target directory are treated as applications and
# run by the server when requested rather than as documents sent to the
# client. The same rules about trailing "/" apply to ScriptAlias
# directives as to Alias.
#
ScriptAlias /cgi-bin/ "cgi-bin/" Alias /allbridaljewelry "C:/wamp/www/newStore" Alias /caketopshop "C:/wamp/www/newStore"
Alias /myspecialparty "C:/wamp/www/newStore" Alias /superweddingday
"C:/wamp/www/newStore" Alias /weddingfavorsmart
"C:/wamp/www/newStore"
You could check this How to setup our own domain when in a developing stage (not localhost)/
It is in Indonesian, but you could try translate.google.com to translate this.
Hope it will be a help.
Let say your main store is http://localhost/opencart-1.5.6.1
Create your multistore (store name Malaysia) and the URL is http://localhost/opencart-1.5.6.1/malaysia/
Open file C:\xampp\apache\conf\httpd.conf and add this code Alias /opencart-1.5.6.1/malaysia "C:/xampp/htdocs/opencart-1.5.6.1/" code after ScriptAlias /cgi-bin/ "C:/xampp/cgi-bin/"
Restart Apache process and try to access this URL http://localhost/opencart-1.5.6.1/malaysia/

Rewrite everything to a single 'site down' page with Zeus Rewrite Rules

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

Is possible to intercept a request for a nonexistent file with lighttpd?

Is it possible to configure lighttpd so that a request for a file succeeds if the file exists, but is handled and redirected, for example to a cgi script, if the file does not exist?
What I'm trying to achieve is having a set of image files on disk which are generated by a script and served directly. On a request, if the file does not exist, the script will generate the image and save it to disk (for future requests) and then either serve the image directly or redirect back to the same URL which will this time succeed. I'm essentially caching the generated output on disk.
I currently have a prototype in which the script always handles the request, reading and echoing the file if it exists, but I'd rather save the overhead and have lighttpd serve it directly if possible.
You can have the best of both worlds. Lighttpd will serve the file if you give it a
X-Sendfile: path to file
see: http://redmine.lighttpd.net/wiki/1/X-LIGHTTPD-send-file. There's a php example on the documentation page.
You can set the:
server.error-handler-404
config option to a script which will do what you want.
see http://redmine.lighttpd.net/wiki/1/Server.error-handler-404Details
This question may be old, but it asked exactly what I wanted an answer to. Here is the solution that I came up with...
Here is a complete, and minimal, working configuration file for Lighttpd.
server.document-root = "/srv/http"
server.port = 80
server.username = "nobody"
server.groupname = "nobody"
server.dir-listing = "enable"
server.stream-response-body = 2
server.modules = (
"mod_rewrite",
"mod_alias",
"mod_cgi"
)
url.rewrite-if-not-file = ( "^/alpine/.*\.apk$" => "/fecher" )
alias.url += ( "/fecher" => "/bin/fecher" )
$HTTP["url"] =~ "^/fecher$" {
cgi.assign = ( "" => "" )
}
This sits on a server where I store package files. It directly serves any files it has and requests for anything it doesn't are delegated to a CGI script called /bin/fecher.
The url.rewrite-if-not-file rewrites any URL matching the given regex to /fecher.
the URL /fecher is aliased (changing its document root) to /bin/fecher.
CGI is enabled for URLs matching the regex ^/fecher$ (i.e. only /fecher).
the server.stream-response-body setting prevents Lighttpd buffering the CGI output into a temporary file (I did not want to provide it with write access to /var/tmp or anywhere else).
If the server encounters a URL matching the first expression for which it lacks the file, the URL gets rewritten and mapped to the CGI script which is executed.
On my server /bin/fecher is a shell script that pulls the missing package from upstream, returns it to the client and stores it locally for future requests.

Resources