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!
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
I am unable to login into magento admin.
In magento, (in newest release..)
it needs proper domain to login ...but how it is
possible in a local machine...
I found some solution ...in magento forum here...
http://www.magentocommerce.com/boards/viewthread/4337/P15/
They asked to change localhost to h t t p ://127.0.0.1
but when tried it redirects to localhost...?!
Kindly suggest.
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;
}
?>
I'm migrating some code from a working web app, but can't get it to work on the new server. Everything seems to be configured correctly, but I'm getting internal redirect limit errors in Apache2. Here are my rewrites and explanation
This WORKS - any subdomains that aren't cdn. or manage. should be redirected to u.php
RewriteCond %{HTTP_HOST} ^(^.*)\.mediasprk\.com$ [NC]
RewriteCond ^(.*)$ !^(cdn|manage)$
RewriteCond %{REQUEST_URI} !\.(png|gif|jpg)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ u.php?uri=$1&hostName=%{HTTP_HOST}
This is no longer working. Goal here is to handle CName pointing. So if it's not my app domain (mediasprk.com), then handle it by sending it to u.php.
RewriteCond %{HTTP_HOST} !^mediasprk\.com$ [NC]
RewriteCond %{REQUEST_URI) !\.(png|gif|jpg)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ u.php?uri=$1&hostName=%{HTTP_HOST}
Can anyone see the issue here in the second block that would cause the redirect limit errors? Maybe something wrong in the rewrites? Thanks.
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 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.
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?
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 was trying to install the mcrypt libraries following this tutorial (http://www.glenscott.co.uk/blog/2011/08/29/install-mcrypt-php-extension-on-mac-os-x-lion/), but something must have gone wrong and now when I load a php page on my localhost I see this:
query="SELECT DISTINCT ".$field." as a,".$field2." as b FROM ".$tab." ".$where. " Group by ".$field." order By ".$orderBy; return $this->query; }
And all the remaining code of the php page that should get loaded.
I've retrieved the previous versions of the private/etc folder and usr/lib/php folder with time machine but it didn't help.
And now if I execute sudo pachectl restart it gives me this error: sudo: no valid sudoers sources found, quitting (while before it worked.
PS I'm on a mac with Mountain Lion
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 want to rewrite URLs so when a user goes to;
http://www.example.com/applications/newWeb/www/index.php?page=48&thiscontent=2660&date=2013-10-11&pubType=0&PublishTime=09:30:00&from=home&tabOption=1
and if the URL contains thiscontent=2660 (which in this example above, it does) I want to redirect them to;
http://www.example.come/index.php/publications/finance-and-economics/departmental-resources
I have about 30 different thiscontent=XXXX types and imagine I’ll have to copy and edit this rule 30 different times for any links to my old website still knocking around out there.
I have access to my httpd.conf file but have never done a mod_rewrite before.
I also don't really need these showing up in the error logs as 301s. Will that happen? Because at the moment there are hundreds!
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
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?
I would like to set/change the delay of a File consumer at runtime through JMX.
I am able to change the value of the property but it doesn't seem to be taken into account until I restart the consumer.
Example with the camel-archetype-java and its basic file example:
Run It
Change the delay of the File Consumer by calling the setDelay Operation with the JConsole
Delay property of the Consumer is changed but logs show it continues to poll at 500ms by default
Stop/Start the consumer
New value of delay is used by the consumer
Do I need anothers steps or active any configuration to make it work at runtime?
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'm using Drupal 6. Typically, when the user requests a URL for which Drupal has no response, it uses index.php as the error document. However, I'd like to suspend this behavior for a specific URL. How can I do this?
RewriteCond %{REQUEST_FILENAME} !=fail
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
Where "fail" is the path I want to block. So www.example.com/fail should result in a 404.
Incidentally, what does [L, QSA] do? I've looked at documentation without luck.
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 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.
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 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 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.
Here I am stuck with my htaccess code. I have been trying to figure it out for the last 11 hours why am I getting a redirect loop for the below code.
Options -Indexes +FollowSymLinks
RewriteEngine on
#Check for no www or www
RewriteCond %{HTTP_HOST} ^dummysite.com$ [or]
RewriteCond %{HTTP_HOST} ^www.dummysite.com$ [NC]
RewriteRule . - [E=FIRSTPART:true]
# IE 6
RewriteCond %{HTTP_USER_AGENT} !MSIE\s6
RewriteCond %{ENV:FIRSTPART} true
RewriteRule ^(.*)$ https://www.dummysite.com/$1 [R=302,L]
Why the above code results into a redirect loop?
EDIT: What I actually want is that if the user is from IE6 then he should be redirected to http version with www as prefix no matter if he types www or not in the url. And on the other hand if the user is from any other browsers then he should be redirected to a https version with www as prefix no matter if he types www in the url or not.
Is it possible to use mod_negotiation to serve up a webp image if the browser supports it, and a jpg otherwise?
For instance, if I link to an image with the path /images/test, it serves the image found at /images/test.webp if the UA knows about webp, or jpg otherwise?
I've tried poking around, but it seems that the Accept headers in Chrome at least look like Accept:*/*, rather than specifying the image type.
If this isn't the way to do it, has anyone got any other suggestions?