htaccess clean urls without modifying base url

I'm trying to clean the url

/file.php?page=[whatever]

to

/file/[whatever]

using .htaccess. The file.php resides in the root public_html folder.

The below code works perfectly, but even though I've specified the file type as php it still applies to other files (such as css) and breaks links!

The two solutions I've found on the internet are:

  • Avoid relative links to external files and include the full path

  • add my domain in the base tag to the head of every .html page

I don't want to do either of these as they make me unable to work on the site locally with MAMP/XAMPP.

RewriteRule ^file/([^/\.]+)/?$ file.php?p=$1 [L]

Steam Post Request – Failed to load resource: the server responded with a status of 400 (Bad Request)

I'm trying to send a post request like this:

xhr.open("POST", "/steamapi/actions/RemoveFriendAjax", false);
    var params = "sessionID="+session_id+"&steamid="+id;
    xhr.onreadystatechange = function() {//Call a function when the state changes.
        if(xhr.readyState == 4 && xhr.status == 200) {
            alert(xhr.responseText);
        }
    }   
xhr.send(params);

I'm using an Apache Server, and this is my .htaccess file

RewriteEngine On
RewriteRule ^api/(.*)$ http://api.steampowered.com/$1 [P]
RewriteRule ^(.*)$ http://steamcommunity.com/$1 [P]
 <IfModule mod_headers.c>
    Header add Access-Control-Allow-Origin "*"
    Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
    Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
 </IfModule>

Whenever I send the request I get this error:

Failed to load resource: the server responded with a status of 400 (Bad Request) 
enter code here

Why is this happening? I have used GET requests with Steam and they work fine, put this POST request doesn't seem to be working.

EDIT: This is steamcommunity.com's robot.txt file:

User-agent: *
Disallow: /actions/
Disallow: /linkfilter/
Host: steamcommunity.com

It says Disallow: /actions/, so is this the reason why I'm getting a 400 error?

Apache PHP performance [on hold]

So I have the little prime number calculator.

<?php
$number=$_GET['number'];
echo 'Input: '.$number.'<br><br>';

if((string)(int)$number == $number) {
        if($number>1 && $number<10000000){
            $status=0;
            $x=2;
            while($status==0){
                $y=$number/$x;
                if((string)(int)$y == $y){
                    $status=1;
                    echo 'Sorry. '.$number.' is not a prime number.';

                }
                if($x+1==$number){
                    $status=1;
                    echo 'Yes. '.$number.' is a prime number.';
                }
                $x++;


            }

    }
    else{
    echo 'Please specify a number between 1 and 10.000.000';
    }
}
else{
    echo 'Please specify a number. May not contain decimals, dots or commas.';
}

?>

How can I know how much server power it uses to calculate a high number. It could be nice if I could allow a higher number than 10 millions without people sucking all the resources.

Question: How do I know how long it took to perform the task and how do I know how many percent of the cpu and ram it used?

403 Access Forbidden with XAMPP

I've set up a Virtual Host with XAMPP for a site I'm making. I can load the main index file fine, however I noticed my stylesheet was not loading at all. When navigating to the stylesheet directly through the browser I'm met with the 403 error:

Access forbidden!

You don't have permission to access the requested object. It is either read-protected or not readable >by the server.

If you think this is a server error, please contact the webmaster.

I have many other sites in my xampp/htdocs folder although they have no problems. I'm only getting these errors with the project using the virtual host. Here's the relevant section of my apache/conf/extra/httpd-vhosts/conf file:

  <VirtualHost *:80>
    DocumentRoot "C:\xampp\htdocs"
    ServerName localhost
  </VirtualHost>
  <VirtualHost *:80>
    DocumentRoot "C:\xampp\htdocs\ozanamclub\craft"
    ServerName craft.dev
  <Directory "C:\xampp\htdocs\ozanamclub\craft">
        Allow from all
        Require all granted
  </Directory>
  </VirtualHost>

Everything loads fine in the above directory "C:\xampp\htdocs\ozanamclub\craft" but if I try and load my CSS file which is in "C:\xampp\htdocs\ozanamclub\craft\craft\css\styles.css" I get the 403 error.

Any help?

Can a website use multiple .htaccess files if it exists multiple times in the file tree?

I was actually wondering,

If I'd put a .htaccess in the /public_html folder and inside the /public_html/example_site/, would the pages inside /public_html/example_site/ use both of them?

And which of the two would be in favor, in case of conflicting arguments?

Use case
There are some rules I want to apply to every website I host, but there are some site-specific .htaccess rules. Therefor I would like to use two (or more) .htaccess files.

.htaccess rewrite rule for two GET variables HTTPS to HTTP

I have successfully been able to redirect my two variables using the following code, but if the search engine indexes it as https, then I have not been able to find a way to redirect it to the non secure version.

Code for redirect:

RewriteRule ^(.*)\/(.*)\.html$ group/user.php?uid=$1&page=$2 [L]
RewriteRule ^([^/\.]+)/?$ group/user.php?uid=$1 [L]
RewriteRule ^([^\/\.])+[\/]([^\/\.]+)[\.]html$ group/user.php?uid=$1&page=$2 [L]

Correctly makes: testdomain.com/test/page.html

but somehow the page got indexed in google as a secure page, and I cannot for the life of me figure out how to create a redirect from the https version to http.

My goal is to take https://www.testdomain.com/test/page.html and redirect to http://www.testdomain.com/test/page.html

Any help would be very helpful.

Wildcard Subdomain to subfolder

how can I do that when a user enters to a subdomain (I'll have a wildcard subdomain), he will see what in the subfolder with the same name in the main domain? For example, if user will enter to works.domain.com, I want him to see what's in www.domain.com/works. Another example: user will enter to private.domain.com/photos/gallery.php?from=germany&no=3, he'll see what's in www.domain.com/private/photos/gallery.php?from=germany&no=3.

What should I write in the HTACCESS of the wildcard subdomain? Thanks!

Updating PHP on CentOS 6.5

I've spent 5 hours trying to resolve this issue. I've used every suggestive link that was relevant to my issue that Google listed. Nothing seems to work.

The OS is CentOS 6.5 and has Apache, PHP, and MySQL installed. I have several WordPress intranet sites working for almost a year with my subdomain xxxxx.xxxx.com.

First of all, I updated PHP 5.3.3 to the latest version. After that I got the error that MySQL extensions were not installed. I followed the different resolutions I could find and could not get a resolve. I therefore decided to remove php and install the older version I originally had. Since that time I am running into three problems.

  1. My domain now only shows the Apache page whereas it use to show my website;

  2. When I try to find out what php version I have by using the command php -v I would get what version was installed. After removing the updated version and installing the older one I get the error "php: command not found";

  3. When I try to remove the older version I can't find it's install location and phpinfo.php doesn't work (may have put it in the wrong place)

Any help resolving this issue would be greatly appreciated