Tag Info

Hot answers tagged

119

mod_rewrite syntax order mod_rewrite has some specific ordering rules that affect processing. Before anything gets done, the RewriteEngine On directive needs to be given as this turns on mod_rewrite processing. This should be before any other rewrite directives. RewriteCond preceding RewriteRule makes that ONE rule subject to the conditional. Any following ...


22

What is the fundamental format and structure of mod_rewrite rules? I'll defer to sysadmin1138's excellent answer on these points. What form/flavor of regular expressions do I need to have a solid grasp of? In addition to the syntax order, syntax matching/regular expressions, and RewriteRule flags outlined by sysadmin1138, I believe it bears ...


18

This is the cleanest way to do what you want: mutt -a <(mysqldump mysqldumpoptions) admin@example.org The <() operator is what you were asking for; it creates a FIFO (or /dev/fd) and forks a process and connects stdout to the FIFO. >() does the same, except connects stdin to the FIFO instead. In other words, it does all the mknod stuff for you ...


7

TLDR; It is not possible to obscure WordPress by only using directives in your .htaccess file. Now cometh a tale of woe and horror. Our friend, fbh was right about the difficulty in hiding WordPress, it be not for yellow-bellied cowards. Arr! Here be the details of this (mis)adventure. Ye be warned! Motivation I'm one of those guys that likes things ...


6

Add tedswigets.com to your virtual_alias_domains list and then in your virtual file add: @tedswigets.com @tedswidgets.com According to virtual(5) when the result has the form @otherdomain the result becomes the same user in otherdomain. So @tedswigets will catch all anyuser@tedwigets.com emails and the @tedswidgets in the result will cause it ...


6

stdout is the screen. There isn't a separation between stdout and "the screen". In this instance, I would just redirect stdout to stderr temporarily with 1>&2 within a subshell. This will cause the commands' output to be shown on screen but won't be in the programs stdout stream. #!/bin/bash # the output of these commands shouldn't go to STDOUT, ...


6

What are the most common mistakes/pitfalls when writing rewrite rules? A really easy pitfall is when you rewrite URLs that alter the apparent path, e.g. from /base/1234/index.html to /base/script.php?id=1234. Any images or CSS with relative paths to the script location will not be found by the client. A number of options to resolve this can be found ...


6

Like many admin/developers I've been fighting the intricacies of rewrite rules for years and am unhappy with the existing Apache documentation, so I decided as a personal project to get to the bottom of how mod_rewrite actually works and interacts with the rest of the Apache core, so over the last few months I've been instrumenting test cases with strace + ...


6

Using rewritemap There are lots of things you can do with rewritemaps. Rewritemaps get declared using the Rewritemap directive, and can then be used both in RewritCond evaluations, and in RewriteRule Subsitutions. The general syntax for RewriteMap is: RewriteMap MapName MapType:MapSource For example: RewriteMap examplemap txt:/path/to/file/map.txt ...


5

That script makes my eye bleed. Get rid of all of the variables storing fragments of the command (and the unnecessary input redirect on the grep), and see where that gets you. The quoting is almost certainly screwed up in ways you don't even want to imagine. In bourne shell, I'd write something like this: today="$(date +"%m\/%d\/%y")" filetoday="$(date ...


4

If you are trying to hide that you are using wordpress because of crackers, then you really got some work to do. If you do the wp* trick, what about wp-content and wp-includes? Without being able to reach those, you will break the page and it will look horrible. Also, there are so many things in Wordpress that this really takes some work - and you will ...


4

Why can't you just setup a .htaccess file (with a 301 redirect) in the folder that the subdmain is in. For Example: Create a .htaccess file in the folder example.org/subdomain Setup your subdomain in Cpanel based on the above folder Edit that new .htaccess file and add the following code Redirect 301 / http://somethingelse.com With / being the root ...


4

It would probably work but it will be difficult to maintain. Performance will start to take a hit as you increase the number of directives, so if there are patterns in your redirects, you may look to bundle them into a single directive (if you can). It would be architecturally superior to knock together a quick script that looked up the redirection from a ...


4

You mean like get-mailbox -Filter { ForwardingAddress -like '*' } | select-object Name,ForwardingAddress ? Or rather "Inbox rules" which your users would have created in Outlook or OWA? The latter should be trickier, but piping $mbox = Get-Mailbox; $mbox | Foreach { Get-InboxRule -Mailbox $_ } (Ryan, thanks for testing and correcting the syntax here) ...


4

DNS isn't the tool to use to solve this. You can do this with an active/passive load balancer, but if you were going to do this, you might as well just make them both public facing and active/active. What is the business case for having an internal redirect instead of using a real HA solution?


3

It could be a stickiness value being added by a load balancer somewhere. It should only be added to the query string if cookies are disabled. However, the fact that it breaks your code should worry you. Your code should be robust enough to handle this situation. It merely needs to ignore extra query parameters. You may be able to solve this with a ...


3

You can exclude each sub1, sub2 individually like so; <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} ^sub1\.domain\.com [NC] RewriteRule ^(.*) - [L] RewriteCond %{HTTP_HOST} ^sub2\.domain\.com [NC] RewriteRule ^(.*) - [L] RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC] RewriteRule ^(.*) http://www.domain.com/$1 [L,R=301] ...


3

What you need is some sort of load balancing system. Load balancing systems can be implemented in several different ways. A few of these are: Dedicated load balancing server - this device sits in "front" of your back-end nodes and directs requests to one or more of them depending on whatever conditions you set. DNS Failover - automation built into your DNS ...


3

You can, in theory, proxy requests for a subset of the URL space -- when your webserver receives the request for, say, /buying/foo/bar, it makes a request to http://outsourced.example.com/foo.com/buying/foo/bar, and then sends the results it gets for that request to your client. I say "in theory", because it's really not such a hot idea -- it increases ...


3

Yes, it's called cloaking. It basically works by creating a frame that occupies the entire browser window, then loads the target page in the frame. e.g. <frameset rows="100%,*" border="0" frameborder="0"> <frame name="__main" src="http://www.example.com/" noresize frameborder="0"> </frameset>


3

You could use a reverse proxy. If you're using apache, this is what a basic reverse proxy setup would look like for http://myservers. This let you map directories to backend or even remote servers. ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass /svn http://svnvm ProxyPassReverse /svn http://svnvm ...


3

Name servers do not route anything. Name servers respond to requests for names, and they eventually returns an IP. CNAME records return a name, which is then looked up to get the IP. The only thing you really can do with your DNS records is make sure that your name is set returns the IP address of a server that will accept the traffic and do what you ...


2

The code behind NGINX probably uses the FASTCGI variable SERVER_PORT to determine where to direct the user. SERVER_PORT will contain the port nginx listens on, so that would be 8000 in your case. You can try something like this for testing purpose: location ~ \.php$ { [...] fastcgi_param SERVER_PORT 80; } adapted to your configuration. ...


2

I found the answer to this question by more carefully reading the HttpCoreModule docs. port_in_redirect off; This retains the port used by the client during redirects. Closely related is server_name_in_redirect which uses the first hostname for redirects. As I didn't want sitename.v.myserver.com to redirect to sitename.com,


2

You can try the following rules. iptables -A INPUT -i eth0 -p tcp --dport 3306 -j DROP iptables -A INPUT -i lo -j ACCEPT iptables -A INPUT -i eth0 -p tcp --dport 53306 -j ACCEPT iptables -t nat -A PREROUTING -p tcp -m tcp --dport 53306 -j DNAT --to-destination :3306 Assuming eth0 is the public interface. You will be able to access mysql port locally using ...


2

You will first have to check that you have activated virtual hosting and ensure that the module mod_rewrite is loaded. Then, write in your file httpd.conf or a separate file your different virtual hosts: start with the virtual hosts for domain.com, dev.domain.com and mail.domain.com then, configure virtual hosts for development.domain.com, ...


2

There are numerous ways to achieve this, but assuming that you control only the DNS server, you are on the right track: Configure the DNS zone so that the MX points to the correct name of the Exchange server (not the IP address) Have the Exchange server admins deal with accepting email for the domain and the required mapping between ...


2

Try: "Get-Childitem $(Get-Content test)" | Invoke-Expression or "dir $(type test)" | iex Invoke-Expression is roughly equivalent to Bash's eval. It's a good idea to be cautious of any security implications of its use.


2

You'll need to set up your webserver to send a redirect to the browser. Here's how I do this in Apache. Point both the DNS records to the same IP address (for example with a CNAME alias), and place the below code in a virtualhost that listens on this address. You'll also need to have mod_rewrite enabled. # Do an external redirect: # Places www in front of ...


2

As andrushka and Martijn Heemels said, you need to configure a web server to redirect clients to the www. address. But since this is https we're talking about, it's more complicated than that. When the browser client opens an SSL connection to to the server it thinks of as www.domain.net, it expects the server to respond with a certificate that's valid for ...



Only top voted, non community-wiki answers of a minimum length are eligible