redirect

log4j redirect stdout to DailyRollingFileAppender

I have a java app that uses log4j. Config: log4j.rootLogger=info, file log4j.appender.file=org.apache.log4j.DailyRollingFileAppender log4j.appender.file.File=${user.home}/logs/app.log log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%d [%t] %c %p %m%n So all the log statements a...

301 Redirect after a route is matched but before controller execution

I'd like to add a trailing slash to any url's that match a valid route but do not currently end in a slash, i.e. www.example.com/url After a url is matched to a valid route I would like to 301 redirect to the same url but add the trailing slash i.e. www.example.com/url/ I've spent some time looking into it but I can't seem to figure it...

Django and urls.py: How do I HttpResponseRedirect via a named url?

I'm writing a member-based web application, and I need to be able to redirect the page after login. I want to use the named url from my urls.py script in my views.py file for the login application, but I can't for the life of me figure out what to do. What I have is this: def login(request): if request.session.has_key('user'): if requ...

Redirect to older page in php?

Lets say, user go to "profile.php" page, but it requires login. Then it redirects to login page. But after login, it should redirect back to profile.php page. How do i do that? How to get current URL in php? $_SERVER['URI']???? ...

301 redirect .htaccess

Im trying to request the following entire site 301 redirect: word.something.blah.domain.com --> http://www.word.com I don't know how to write the 301 redirect rule. Can someone help out? ...

Removing the query string for SEO improvements.

I just came across this: http://www.askapache.com/htaccess/mod_rewrite-tips-and-tricks.html --> check under "removing the query string". It states: "On many sites, the page will be displayed for both page.html and page.html?anything=anything, which hurts your SEO with duplicate content. An easy way to fix this issue is to redirect extern...

bash: tee output AND capture exit status

I want to execute a long running command in bash shell, and both capture its exit status, and tee its output. So I do this command | tee out.txt ST=$? The problem is that the variable ST captures the exit status of tee and not of command. How can I solve this? Note that command is long running and redirecting the output to a file to...

Apache redirect 404 for only the files that are not found?

What I'm looking to do is basically take all requests to a directory, and if the file exists, send it. If not, send it from the parent directory (assume it exists there). The files are large and there can be a lot, and the subdirectories will change frequently, so filesystem links isn't a great way to manage. Is there some Apache conf...

Htaccess Redirect

I am looking to make www.purchase.example.com redirect to purchase.example.com, below is an example of what I am trying to do: RewriteCond %{HTTP_HOST} ^www\.purchase\. RewriteRule (.*) http://purchase.DOMAIN_NAME/$1 [L,R] I need a variable that will replace DOMAIN_NAME with simply purchase.example.com. Obviously I can hard code the ...

php to htaccess rewrite - redirect if no $_POST data

if( count( $_POST ) < 1 ) { // determine if this was a secure request - we use a non standard HTTPS port so the SERVER_HTTPS_PORT define should always be used in place of 443 $protocol = $_SERVER['SERVER_PORT'] == SERVER_HTTPS_PORT ? 'https' : 'http'; header( "HTTP/1.0 301 Moved Permanently" ); header( "Status: 301" ); /...

Rails/Passenger/Apache: Simple one-off URL redirect to catch stale DNS after server move

One of my rails apps (using passenger and apache) is changing server hosts. I've got the app running on both servers (the new one in testing) and the DNS TTL to 5 minutes. I've been told (and experienced something like this myself) by a colleague that sometimes DNS resolvers slightly ignore the TTL and may have the old IP cached for some...

Redirect 301 with hash part (anchor) #

Hello everyone, One of our website has URL like this : exemple.oursite.com. We decided to move our site with an URL like this www.oursite.com/exemple. To do this, we wrote a rewrite rule in our Apache server that redirect to our new URL with a code 301. Many websites link to us with URLs of the form exemple.oursite.com/#id=23. The pro...

Redirecting VxWorks shell output to a socket.

I'm aware that it's straightforward to redirect the shell output to a file. So I should also be able to set up a socket and redirect the shell's output to the socket, as essentially it's just another file descriptor (I think)? I've seen some example C programs that create some basic client/server functionality but (as small as they are...

Form Repopulation on Redirect using ASP

I'm currently working on an application that uses ASP, and I am currently having difficulty repopulating the fields of a form after redirecting back to that form. Basically, I have a form where a user can input data into it (Say, an admin creating a new user within the system). Upon clicking the "Submit" button on the form, it goes to ...

PHP header redirect not working

I know this has been covered before but I cannot find an answer to this, I have always used this; header("Location: http://www.website.com/"); exit(); This has always worked in my current project and all of a sudden it is not working in any of my browsers I would like to figure out the problem and fix it instead of using echo "<scr...

Redirect to previous page in zend framework

Hi there, I want to add a redirection URL to my login forms action (as a query) in login page, so after loging-in, one can visit the previous page he or she was surfing. First I thought about using Zend Session and save the url of each page in a variable. but I read in the documentation that it has overhead. So, is there a better way t...

Best redirect methods?

In a PHP file when I need to redirect a user and headers are already sent so I can not use php's header function, in this case which is the best method to redirect a user? Fastest and most reliable method regardless of the users browser brand? echo '<script type="text/javascript">window.top.location="http://localhost/";&lt;/script&gt;'...

How can I redirect in PHP without header errors?

How can I redirect in PHP with this setup below without getting header output errors, I understand that nothing can be printed to the browser before a header is set, I am looking for a solution, not an explanation of why it happens please. <?PHP // include header include ('header.inc.php'); // In my body section file if this is a pag...

Switch hosting providers - redirect users to new site before and after DNS updates propagate

We want to switch hosting providers. To do so will require a DNS update for the IP address associated with our domain. Content has been tested and brought up on the new server. The DNS update has been made but users are not able to see the new site until the DNS propagates (which could be days). Is there a something that can be done o...

.htaccess redirecting errors

First off I am using the Codeigniter Framework so this issue is a workaround the way CI process URLs along with the current redirects I have set up using mod_rewrite. I am trying to get a URL like this /?gclid=somestringgoeshere to redirect to /index.php?/home/gclid/somestringgoeshere. The current .htaccess I have set is below <IfModu...