I basically want to debug a cgi programm with gdb by emulating the environment variables and stdin stream.
How do I set the variables and stdin?
I am using lampp and gdb.
Thanks!
Hello all,
I am running wampserver on my windows vista machine. I have been doing this for a long time and it has been working great. I have completed loads of projects with this setup.
However, today, without me changing anything (no configuration etc) only PHP code changes, I find that every time I load pages of my site (those with user sessions or access the database) are really slow to load - Over 30 seconds, they use to take 1 or 2 seconds.
When I have a look at the task manager, I can see on page loads the httpd process jumps from 10mb to 30mb, 90mb, 120mb, 250mb and then back down again.
I have tested previous php code projects and they seem to all be slow as well!
What is going on?
Thanks all for any help on this confusion issue!
I just upgrade the PHP version in my VPS to 5.3.2
I used FastCGI and worker MPM in php 5.1.2 or 5.2.1 I forgot, it worked fine, and it was so fast, I like it.
After I upgrade the PHP version, it gives me Internal Server Error 500 on all .php pages.
What is wrong? does FCGI support php 5.3.2?
If yes, there should be some differences in setting it up? what should I change to get it back working?
Thank You
Hi! I'm trying to get my head around RewriteCond, and want to rewrite any requests either to a static html page (if it exists), or to a specific index.php (so long as the requested file doesn't exist).
To illustrate the logic:
if HTTP_HOST is '(www\.)?mydomain.com'
if file exists: "/default/static/{REQUEST_URI}.html", then
rewrite .* to /default/static/{REQUEST_URI}.html
else if file exists: {REQUEST_FILENAME}, then
do not rewrite
else
rewrite .* to /default/index.php
I don't seem to have much trouble doing it when I don't need to test for the HTTP_HOST. Ultimately, this one .htaccess file will be handling requests for several domains.
I know I could get around this with vhosts, but I'd like to figure out how to do it this way.
Here's where I am at now:
RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com$ [NC]
RewriteCond /default/static/%{REQUEST_URI}.html -f
RewriteRule . /default/static/%{REQUEST_URI}.html [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /default/index.php [L,QSA]
I'm not too familiar with some of the other flags, will any of them be of use here (like chain|C, next|N or skip|S)?
Thanks in advance!
UPDATE: I've managed to do it, but would appreciate alternatives:
RewriteEngine On
RewriteRule ^(.+)/$ /$1 [L]
RewriteCond %{HTTP_HOST} ^(domainA|domainB)\.com [NC]
RewriteCond %{DOCUMENT_ROOT}/%1/static/%{REQUEST_URI}.html -f
RewriteRule (.*)? /%1/static/$1.html [NC,L]
RewriteCond %{HTTP_HOST} ^(domainA|domainB)\.com [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* /%1/index.php [L,QSA]
i am running this simple command { ./a.out < in; } & output.txt using exec and i want to output what's coming in output.txt through ajax request continuously. Also i want a way to turn off my output buffering.I tried flush() and ob functions but didn't succedded.In my /etc/php5/apache2/php.ini php.ini value of output_buffering = 4096.When I change it to Off and restart my apache2 server it fails to restart.P.S. I am using lamp server.
This is the Htacces rule:
RewriteEngine on
RewriteRule ^([A-Za-z0-9-]+)/?$ ir.php?id=$1
how should I pass it to a Nginx compliant rewrite rule... i read the doc and did this:
rewrite ^([A-Za-z0-9-]+)/?$ ir.php?id=$1 last;
But didnt work.
and another question:
Is there any equivalent of .htaccess to Nginx (per directory rules)
Thanks
We've got our ETags and expiry headers setup properly and when browsing around the site without posting it is really very snappy. However, after any POST (which is almost invariably followed with a 302) you can see the browser re-request all the images. Is there something that could be causing this? Is there a setting that handles this?
We did some maintenance today, and moved our web forums from /forums into the root folder of the domain.
We put in a redirect 301 in a .htaccess file:
Redirect 301 /forums/ http://www.ourforums.com/
However, we used to have some links that contained duplicate /forums folders. I.e. www.ourforums.com/forums/forums/forum.1
Obviously the redirect from above now leads to /forum.1, which odes not exist. I would like the old link to actually point to www.ourforums.com/boards/forum.1. I attempted to use something like:
RewriteRule ^/forums/forums http://www.ourforums.com/boards/ [NC,R=301,L]
Regardless of what I tried though, the Redirect seems to supersede any RewriteRules I put in the same file, regardless of whether I place them before the Redirect.
Is there any way I can somehow ensure the RewriteRule is handled before the Redirect?
I am thinking about setting the
php.ini, my.cnf and httpd.conf default charsets=UTF-8
The website is in swedish lang only.
I have some folders with special chars in them, also some files.
Is there any harm by doing this?
Is it cross-browser safe?
Thanks
I'm currently using .htaccess to rewrite on my website to create dynamic subdomains. I also use it to remove the .php extension on all pages. However, once inside the subdomain, it tries to redirect again. For example, if you went to https://admin.example.com/test, it would actually be accessing https://example.com/clients/admin/test.php. I keeping getting various 404 errors using the following .htaccess file:
Options +MultiViews
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^subdomains/(.*)/(.*) http://$1.example.com/$2 [r=301,nc]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteCond %{HTTP_HOST} !^(www\.)?example\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.example\.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}/%2%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} !^(www\.)?example\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.example\.com$ [NC]
RewriteRule ^(.*)$ clients/%2/$1 [QSA,L]
How can I keep this from redirecting to https://admin.example.com/clients/admin/test.php?
I cant seem to send an email using PHP's mail(). I have also tried PHPMailer and Swiftmail with no success. However, the following command on the server delivers mail successfully.
cat test.txt | mail -s "test mail" [email protected]
Is there a way to trace where the problem is coming from? mail() just seems to return true or false.
Hey everybody.
I've been trying to solve this for hours now but came up with nothing.
Inside .htaccess, whenever somebody requests an image from a folder of my website, I'm trying to check if a file with the same name exists in another folder; if it does, return that file; if it doesn't, return the file originally requested.
It seems so easy but it simply doesn't work. The .htaccess code is as follows:
RewriteEngine On
RewriteCond /images/blog/watermark/$1 -f
RewriteRule ^(.*) /images/blog/watermark/$1
The "RewriteCond" always returns negative, so the image requested is always loaded as is. If I change it to, like,
RewriteCond %{REQUEST_FILENAME} -f
it always returns positive, so it gets the image from the folder I want - except when the image's not there, generating an error, which is exactly what I'm trying to prevent.
What am I doing wrong?
Thanks.
I want example.com/23-45 be transformed to example.com?id=23-45
Could you please post the code I should add to .htaccess file to make this work
(Is this everything I should do to make this work - add a piece of code to .htaccess file ???)
Thanks a lot!
I have site with these files and foldes:
/index.php ( that include php files contained in folder1 and folder2 )
/config.php
/folder1/
/folder2/
I want this:
when a user point to any folder ( folder1, folder2 or any other folder ) then he is redirected to index.php
How could I do that ?
I have a domain, for example, http://example.com. It is already configured to point to
/var/www/
Basically, i want http://example.com to point to
/var/www/4.0/
and http://example.com/foobar/ to point to
/var/www/moo/
How can I do this with the httpd.conf file for Apache2? Thanks
I have a website right now that uses two languages (french and english) The way it works right now is that if someone goes to mysite.com/folder/file.php for example, file.php is simply a script that figures out which language to use, get's it's own path and filename(file.php) and serves up mysite.com/en/folder/file.php (if the language is english). However what shows up in the URL is still mysite.com/folder/file.php.
For any folder and any file the same script is used. If I want to add a new file I have to add the file to the folder the user types into the browser as well to the en and fr folders. Could I do some .htaccess trickery so that whatever URL is typed, one .php file gets open that checks the language and what folder/file was requested and then serves up the correct language file?
here's the php file that is served up for any files in the URL.
<?php
// Get current document path which is mirrored in the language folders
$docpath = $_SERVER['PHP_SELF'];
// Get current document name (Used when switching languages so that the same
current page is shown when language is changed)
$docname = GetDocName();
//call up lang.php which handles display of appropriate language webpage.
//lang.php uses $docpath and $docname to give out the proper $langfile.
//$docpath/$docname is mirrored in the /lang/en and /lang/fr folders
$langfile = GetDocRoot()."/lang/lang.php";
include("$langfile"); //Call up the proper language file to display
function GetDocRoot()
{
$temp = getenv("SCRIPT_NAME");
$localpath=realpath(basename(getenv("SCRIPT_NAME")));
$localpath=str_replace("\\","/",$localpath);
$docroot=substr($localpath,0, strpos($localpath,$temp));
return $docroot;
}
function GetDocName()
{
$currentFile = $_SERVER["SCRIPT_NAME"];
$parts = Explode('/', $currentFile);
$dn = $parts[count($parts) - 1];
return $dn;
}
?>
HI
I do have a list of urls and my site is giving information about indexing and back links of any website out their. so what I want is I do have thousands of website lists with me and I want all that to run and store it in my database. so how do I do it using crone job??
the url address is for example
www.mydomain.com/search?url=www.google.com so
after google.com another one and all which is in the list.
I have a website where I am using SSI to include some stuff to the front page. However, I'd like to show users an URL that ends with .html. I have accomplished that via a .htaccess and mod_rewrite redirect.
RewriteRule ^index\.html$ index.shtml [PT,L]
Also, I am using another redirect pointing to this URL to internally load the pages' content with JavaScript (example.html to index.html#example.html) with a condition for not redirecting index.html.
Now, I'd like to make the .shtml page 403 Forbidden. This is also easy:
RewriteRule ^index\.shtml - [F]
But, now index.html also gets forbidden.
I have tried adding L to the .html-to-.shtml rule, but this doesn't help. How could this problem be solved?
I have a rewrite in htaccess which makes this:
domain.com/ad.php?ad_id=bmw_m3_328942948
into this:
domain.com/ads/bmw_m3_328942948
Problem is the links which are relative to the file wont work...
for instance if a link is pointing at '/bin/edit.php' like this originally:
domain.com/bin/edit.php // WORKS
but after the rewrite the link wants to point here instead:
domain.com/ads/bin/edit.php // NOT WORK - NOTE THE /ads/ DOESN'T EXIST IN REALITY
Do you understand my issue?
What is done about this? Do I have to make ALL links using the newer rewritten format?
.htaccess:
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/ad\.php
RewriteRule ^annons/(.*)$ ad.php?ad_id=$1 [NC,L]
Thanks
I moved my images directory to a different folder, and now I want to redirect all images requests from that folder to the new one.
I do not have access to the main configuraion file, so I'm doing this in a .htaccess.
I tried this, and it works:
RewriteCond %{REQUEST_URI} old_dir/.+.(jpg|png|gif)$
RewriteRule old_dir/(.+[^/]+..+)$ $1 [L,PT]
But since they have permanently moved, I want to do a proper redirect, so I added the [R] flag, like this:
%{REQUEST_URI} old_dir/.+.(jpg|png|gif)$
RewriteRule old_dir/(.+[^/]+..+)$ $1 [L,PT,R]
But the server gets confused, and returns a 400, so I looked at the log file, and this is what happens:
strip per-dir prefix: C:/wamp/www/natrazyle/old_dir/images/banner.jpg - old_dir/images/banner.jpg
applying pattern 'old_dir/(.+[^/]+..+)$' to uri 'old_dir/images/banner.jpg'
rewrite 'old_dir/images/banner.jpg' - 'images/banner.jpg'
add per-dir prefix: images/banner.jpg - C:/wamp/www/natrazyle/images/banner.jpg
explicitly forcing redirect with http://localhost/C:/wamp/www/natrazyle/images/banner.jpg
As you can see, the full local path gets added after localhost
I know I'm doing something wrong, I just can't figure it out myself.
Any help would be greatly appreciated...
I want to create a web page that allows the user to initiate a reboot on the linux server. Obviously this would only be avaliable for system admins and would also be controlled by using iptables.
Below is a sample of code that I was thinking of using but I wanted to know if there is another way to do this and how also to use this in a web page? Also is there any thing else that I should consider?
$command = "cat $pass | su -c 'shutdown -r now'";
$output = array();
try{
echo shell_exec($command);
exec($command, $output);
system($command, $output);
}
catch(Exception $e) {
print "Unable to shutdown system...\n";
}
foreach ($output as $line) {
print "$line<br>";
}
Thanks in advance.
The deal is that I have a ZF site for which root directory is /public. How should I go about redirecting to a subdirectory if I want to do next?
I want to have another subdirectory under /public/ that would not be linked to a main website in any way except it using save ZF. Lets say I have this: /public/newsite/ which will include a complete modular ZF (just I have it for the main site). That is the root directory for the NEWSITE would be /public/newsite/public. So my question how do I modify my .htaccess rules so it would redirect any requests from /public/newsite/ to /public/newsite/public/?
Thank you in advance.
I have a rewrite rule for GET and POST:
<LocationMatch "^/my/script/dir/?$">
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$
RewriteRule .* /resources/scripts/storage/admin/list.php
Script POST /resources/scripts/storage/admin/create.php
</LocationMatch>
How would I modify it to only allow POST?
I want to ensure that regardless of what browser a user is in, they all see the EXACT same characters in the URL bar.
Most browsers show the preceding protocol type in the URL bar. However, Chrome for example truncates http:// (not sure about https) and starts with the domain name, ie:
Chrome: stackoverflow.com/questions/ask
Safari: http://stackoverflow.com/questions/ask
So, is there a way to either suppress the http:// in all browsers, or even enforce it in all browsers? Preferably suppress.