Tag Info

Hot answers tagged

138

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 ...


23

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 ...


20

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 ...


9

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 + ...


7

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 ...


7

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 ...


7

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 ...


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

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) ...


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, ...


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 ...


5

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] ...


5

You need MX records. Period. There may be tricks if they currently don't go to google apps to redirect your mail. But it has to go somewhere to start with. If your host really doesn't let you set MX records (which is unlikely) transfer your domain to someone who does.


4

use scriptable ftp client like lftp. you use it like this: lftp -u login,pass host.com -e "get file.txt;exit " or even simpler - use wget: wget -O file ftp://login:pass@host.com/file.txt


4

Configure your server to issue an HTTP 301 response to map the one to the other, eg using Redirect with Apache.


4

I think you can use something like this: <VirtualHost *:80> ServerName xyz.com ServerAlias *.xyz.com RewriteEngine on RewriteCond %{HTTP_HOST} ^(.*)xyz.com$ RewriteRule ^.*$ http://%1abc.com$0 </VirtualHost>


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

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

Do you mean something like: rewrite ^/component(.*)$ $1 last;


4

Set your DNS MX record for the new short domain to be the same as for your full long name. Configure your mail server to host both Create rewrite rule to rewrite @shortname as @longname


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?


4

If you want to allow legitimate SSH logins while disallowing (via honeypot) fake, I'd change tack. Put your SSHD on another port, like 2323 or some other oddball port, and forward connections to that. Ideally you have a separate machine for that, so you can tell your router to forward port 2323 to internal machine XYZ port 22. Open port 22 to be forwarded ...


4

To address your question about disconnected computers (laptops/notebooks) being joined to the domain. This is very common. When disconnected from the domain, those users who use domain joined laptops/notebooks will log on to the laptops with cached credentials for their domain user accounts (so long as they've logged onto the domain at least once while ...


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

If you're responsible for both Web sites, you could put SQUID in front of them and handle it on the backend. (See: transparent proxy)


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

Something like: $HTTP["host"] =~ "firsthost.example.com|secondhost.example.com|otherhost.example.net" { url.redirect = ( "^/(.*)" => "http://realdomain.example.org/$1" ) } should work - as covered in the man page ;)


3

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,


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 ...



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