Apache Web Server

19K

Solutions

15K

Contributors

The Apache HTTP Server is a secure, efficient and extensible server that provides HTTP services in sync with the current HTTP standards. Typically Apache is run on a Unix-like operating system, but it is available for a wide variety of operating systems, including Linux, Novell NetWare, Mac OS-X and Windows. Released under the Apache License, Apache is open-source software.

Share tech news, updates, or what's on your mind.

Sign up to Post

NOTE: I am working with Phalcon tutorial -
http://docs.phalconphp.com/en/latest/reference/apache.html

This is Apache on Windows.

I have a web page that I can browse to with no issues -
https://localhost:8443/tutorial/index.php

I have set up the rewrite rules in the httpd.conf file (not using .htaccess) -

<IfModule mod_rewrite.c>

    <Directory "c:/Apache24/htdocs/tutorial">
        RewriteEngine on
        RewriteRule  ^$ public/    [L]
        RewriteRule  (.*) public/$1 [L]
    </Directory>

    <Directory "c:/Apache24/htdocs/tutorial/public">
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
    </Directory>

</IfModule>

But when I browse to https://localhost:8443/tutorial/
I get the directory listing of the public folder -

Index of /tutorial/public

Parent Directory
css/
img/
index.php
js/

It takes me to the public folder so it seems that part of the rewrite is working.

Any ideas what I'm missing?

Thanks,

Kevin.
0
Hi,

On my localhost , I have all of my files in a public_html folder to match the directory struture on the server (I won't go into the reasons for that!). So I have

c:/wamp/www/myproject/public_html

In public_html I have an .htaccess file which redirects everything through index.php:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

What I need to do is ensure that all requests eg http://localhost/myproject/somename.php get processed (through index.php) correctly rather than having to write http://localhost/myproject/public_html/somename.php all the time.

I've done a lot of searching on the topic but can't find a solution - not great at .htaccess!

Many thanks
0
Hello, Experts!  We want to redirect ALL traffic to https://ourdomain.com - whether it's http://ourdomain.com OR http://www.ourdomain.com.  Here is our current .htaccess file, hosted at GoDaddy's WordPress Managed Hosting:

# BEGIN GD-SSL
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_USER_AGENT} ^(.+)$
RewriteCond %{SERVER_NAME} ^ourdomain\.com$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
Header add Strict-Transport-Security "max-age=300"
</IfModule>
# END GD-SSL

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase //
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . //index.php [L]
</IfModule>
# END WordPress

++++++++++++++++++
So...  can someone tell me which lines to add / modify in order to accomplish our objective?  Thanks so much!! ~ Scott
0
I have a site www.fakesite.com and I have an SSL cert installed and I can navigate to https://www.fakesite.com no problem.  But I'm trying to create an nginx directive that will automatically redirect non-ssl visitors to https://www.fakesite.com

This didn't seem to work, can someone show me how to do this?

if ($server_port = 80) {
    rewrite ^ https://$host$request_uri permanent;
}
0
When I create a new Netbeans project, it's Properties > Source section of the dialog box will show my web root. For example, when I create an application called 'myApp', NetBeans Properties dialog box would show:

Project Folder: C:\xampp\htdocs\myApp
Source Folder: C:\xampp\htdocs\myApp
Web Root: <Source Folder>

Let's say that C:\xampp\htdocs\myApp has a _css subfolder where I store my CSS files. When I try to provide an ABSOLUTE path in my page like this:

<link rel="stylesheet" href="/_css/main.css" />

Netbeans reports an error:

Failed to load resource: the server responded with a status of 404 (Not Found) (10:41:10:815 | error, network)
  at http://localhost/_css/main.css

Notice above that Apache now thinks my web root is C:/xampp/htdocs instead of C:/xampp/htdocs/myApp. In other words, the '/' somehow is pointing to C:/xampp/htdocs instead of the web root I specified in Netbeans (which is C:/xampp/htdocs/myApp).

Has anyone encountered this problem? And if so, how does a Netbean user make the '/' correctly point to the application web root? Someone has suggested altering the Apache configuration files to point to the appropriate application root, but that would throw off all other applications I create under C:/xampp/htdocs.

Thanks.
0
Let's say my simple .htaccess file looks like this:

RewriteEngine On
RewriteBase /
RewriteRule ^login/*$ public/login.php [L]

Open in new window


To my understanding, if I used the URL of www.mySite.com/login, it should redirect to mySite/public/login.php. In my browser, it would say http://www.mySite.com/login (which is expected), but I'm getting an error saying "Object not found. The requested URL was not found on this server.", so it's evident to me that Apache couldn't find the page I'm asking it to redirect to.

However, in order for me to troubleshoot this, I need to know what URL Apache is trying to redirect to. How can I see what URL Apache is *actually* using?
0
The following directory structure will be the basis of my question:

_css (this is a folder)
    main.css
public (this is a folder)
    login.php

Open in new window


Both _css and public folders are sibling folders.

Here's how my .htaccess file looks like:

DirectoryIndex public/login.php
RewriteEngine On
RewriteRule ^login/*$ public/login.php [L]
RewriteRule ^login/([^/.]_)/?$ public/login.php?a=$1 [L]

Open in new window


Let's say my domain name is www.mySite.com.

When I use the URL http://www.mySite.com, the DirectoryIndex knows to redirect to 'public/login.php'. To make the styles in my style sheet take effect, I have to define my style sheet within 'login.php' as:

<link rel="stylesheet" [b]href="_css/main.css"[/b] />

Open in new window


But notice, the path point of reference is the application root and not the 'public' folder; otherwise, I would've had to define the path to my style sheet as ../_css/main.css instead of _css/main.css.

Now let's say I use this URL: http://www.mySite.com/login/a=logout, the bottom RewriteRule would kick in and redirect me to public/login?a=logout. But I noticed all the style settings in login.php would be gone! Somehow, to make it look normal, I'd have to redefine the path to my style sheet as '../_css/main.css' instead of the original '_css/main.css'. What this tells me is that Apache now thinks its path point of reference is in the public folder instead of the application root as it did before, causing it to be unable to find my …
0
Hi

I wan to block access to all robots except google, yahoo and msn to all of my website AND want to block one directory /i for ALL robots INCLUDING google, yahoo and msn. I have created following robots.txt. Can someone please confirm if this is correct? Also want robot not to kill my server therefore go as slow as they can.

User-agent: Googlebot
Disallow:
User-agent: MSNBot
Disallow:
User-agent: Slurp
Disallow:
User-agent: *
Disallow: /
Crawl-delay: 120
Disallow: /i/


I am using Apache on some machines and others are using Nginx all using CentOS.
0
There are multiple people accessing my website, but either the traffic is too much now, or my server has gotten too slow.
I am trying to improve performance and return cached pages to the users, instead of them accessing the server directly all the time.
I way I thought of to do it is with a reverse proxy, which will return cached pages.
Following the documentation http://httpd.apache.org/docs/current/mod/mod_cache.html and http://httpd.apache.org/docs/current/mod/mod_proxy.html, I have this so far:
1. In the httpd-proxy.conf, this is the section pertaining to the proxy:
<IfModule proxy_module>
<IfModule proxy_http_module>

#
# Reverse Proxy
#
ProxyRequests Off

ProxyPass http://www.mywebsite.com/ http://www.mywebsite.com/
ProxyPassReverse http://www.mywebsite.com/ http://www.mywebsite.com/

<Proxy *>
      Require all granted
</Proxy>

</IfModule>
</IfModule>

Open in new window


2. In httpd.conf:
LoadModule cache_module modules/mod_cache.so
<IfModule mod_cache.c>
    LoadModule cache_disk_module modules/mod_cache_disk.so
    <IfModule mod_cache_disk.c>
        CacheRoot C:\xampp\apache\cacheroot
        CacheEnable disk  /
        CacheDirLevels 5
        CacheDirLength 3
    </IfModule>
</IfModule>

<IfModule mod_cache.c>
    CacheLock on
    CacheLockPath /tmp/mod_cache-lock
    CacheLockMaxAge 5
</IfModule>

Open in new window


In the specified cacheroot folder, there are numerous data and header files (which means that caching is working).
However my website is still being ridiculously slow.
My server is a Win 2008 R2, running Apache 2.4 and MySQL inside XAMPP.

Anything I'm missing?
Thanks.
0
Doing some Rewrites in the .htaccess file for a website that I am actively doing SEO on. I want to ensure I have just one version indexed in Google and it seems like all of my backlinks are pointed to

http://akenterprisesroofing.ca

I do have some code in the .htaccess file now and it does redirect http://www.akenterprisesroofing.ca to the shorter version www.akenterprisesroofing.ca

I want to know how to also include the redirect to get http://akenterprisesroofing.ca to the URL www.akenterprisesroofing.ca as well.

this is my code

RewriteEngine On
RewriteRule ^index\.html$ / [R=301,L]
RewriteRule ^(.*)/index\.html$ /$1/ [R=301,L]

Open in new window

0
With the advent of HTTP/2, the proposed specifications are very exciting. Most exciting of all is the ability for the server to push information out to a web browser without the web browser having to first ask for it. My question is: functions existing PHP to allow us to use the HTTP/2 capabilities? It seems to me, Ajax may no longer be required to perform many functions. Can much of what was previously done with Ajax be done with PHP now? Or will JavaScript be more important than ever because only it can control requests to the server from a user standpoint?
0
I do web hosting and have a few servers some running Apache and others Nginx.

This is a specialised kind of web hosting and all the websites I host have a directory under their public_html (document root) which should not be available to any bots.

I can create robots.txt in every document root directory but that will be too much work for me as there are many websites hosted.

Is there a way I can stop bots to a specific directory for all websites from apache/nginx configuration?
0
Hi,
We have oracle database installed and would like to share our data with others. I would like to develop a simple web service that provide other application to pull data from oracle database for their own use.

I want to use php to start with because this language is the one that I am familiar with compare to any other language. I had developed few interfaces in php to do (create, read, update & delete) CRUD functionalities. We are using Apache as our web server.

For web api, honestly this is something new for me. I need to know how to do the following, assuming extracting employee table from sample table of oracle database (SCOTT account/schema) - (copying data to new table)

1. Create web-api in php to extract employee table (all columns) and output in JSON format.
2. Create php to call this web-api to read extracted employee record (JSON format) and save it to new_employee table under same schema.
3. How to include authentication to this web-api ? so that only specific client can access to this service.

Please don't give me bunch of links unless it really really help me to do specific task as above. I consider myself as beginner to this.  I have read a lot but seems does not giving me better understanding on how to do it, especially using php.

Thanks in advance.
0
Ive been generating self-signed certificates by using the following command:-
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt

And then answer a series of questions:-
Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:
Email Address []:

Which works great, however I want to avoid having to type in  the answers. So my question is:-
Is it possible to enter these questions in the command line, or pass a file in with the answers?

What Im trying to do is build my own hosting admin page, and allow users to generate their own self certified SSL certificates on my ubuntu server, then add the certificates to the vHost configurations of apache.
0
I am starting to develop a small web site on my PC
I already have a ftp server on it, and using dynamic dns from no-ip I can access it with this name cbsl.ddns.net
I forwarded port 80 to my PC on my internet box (like I did for ftp ports)
Now I installed WAMPServer and then WordPress.
Everything looks to be correctly configurered (mySQL db created etc...)
In my browser, when I code localhost/CBSL, I get the WordPress home page
But when I code http://cbsl.ddns.net/cbsl, I get this error

Forbidden
You don't have permission to access /cbsl on this server.
Apache/2.4.9 (Win64) PHP/5.5.12 Server at cbsl.ddns.net Port 80

This shows that the connection works but it is refused.
What did I miss in the config ?
Thanks
0
How to i setup tomcat on eclipse?

screenshot.pngscreenshot2.png
0
Hi

I'm using the script below to redirect old browser to a perl script

The problem is all images are in subfolders under the folder with .httpaccess file

How do I restrict it to only one folder
or ignore the images folder?

MySiteRoot
  |    |
  |    .httpaccess , index.php  
  |
   Sub dir
  |       |
  |        other PHP filles
  |
   images
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} "MSIE [6-8]" [NC]
RewriteRule ^(.*)$ http://mysite.com/cgi-bin/ie.pl [R=301,L]

Open in new window

0
We would like the FQDN https://www.workforcesoftware.com forwarded to http://www.workforcesoftware.com as we don't currently have an HTTPS based offering of the wordpress site.

We have tried a few things in .htaccess but to no avail. Here is the current .htaccess:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Options All -indexes

<FilesMatch "\.(ico|jpg|jpeg|png|gif|js|css|swf)$">
ExpiresActive on
ExpiresDefault "access plus 30 days"
Header unset ETag
FileETag None
</FilesMatch>

<FilesMatch "\.(?i:pdf)$">
ForceType application/octet-stream
Header set Content-Disposition attachment
</FilesMatch>

<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/xml text/css text/plain
AddOutputFilterByType DEFLATE image/svg+xml application/xhtml+xml application/xml
AddOutputFilterByType DEFLATE application/rdf+xml application/rss+xml application/atom+xml
AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript
AddOutputFilterByType DEFLATE application/x-font-ttf application/x-font-otf
AddOutputFilterByType DEFLATE font/truetype font/opentype
</IfModule>


RewriteCond %{HTTP_HOST} ^workforcesoftware\.ca$ [OR]
RewriteCond %{HTTP_HOST} ^www\.workforcesoftware\.ca$
RewriteRule ^/?$ "http\:\/\/www\.workforcesoftware\.com\/canada\/" [R=301,L]

Open in new window

0
Hello,

We are running  webserver on production and during the DR we need to put diffrent IP address in the vurtual host httpd.conf file.  Can we automate without touching the httpd.conf file?
0
Hi,

I tried to update or change the SSL cipher in my WHM. But after the update my main home pages are being redirected to the wrong url. The home pages and other pages now are no longer working. But sub-directories are working. For instance, when I go to:
http://myultratrust.com it forwards me to:

myultratrust.com/public

And testthis.myultratrust.com forwards me to
http://testthis.myultratrust.com/public

It shouldn't be doing that. Don't know what WHM does in the back but it shouldn't be messing around with the folders of a site because of an SSL configuration change. I tried to change things back but WHM doesn't fix it back to the original state. I'm disliking WHM more because I have no idea what it does in the background. :(

This page properly gets forwarded though:

https://secure.myultratrust.com/ to
https://secure.myultratrust.com/diy/login/login.php

And this site works properly still:
http://emailmarketingservicesco.com/ (it's supposed to be a blank page)

I checked in my httpd.conf settings and I have this:

<VirtualHost 173.201.47.54:80>
    ServerName myultratrust.com
    ServerAlias 47.201.173.in-addr.arpa www.47.201.173.in-addr.arpa www.myultratrust.com
    DocumentRoot /home/myultrat/public_html
    ServerAdmin webmaster@myultratrust.com
    UseCanonicalName Off
    CustomLog /usr/local/apache/domlogs/myultratrust.com combined
    CustomLog /usr/local/apache/domlogs/myultratrust.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
    ## User

Open in new window

0
Hi,

I have a domain:
https://secure.myultratrust.com

When a user arrives at this root sub-domain URL it gets 301 redirected by the index

Open in new window

.php:
<?php
    header( 'Location: https://secure.myultratrust.com/diy/login/login.php' ) ;
?>

Open in new window


What I'm trying to do is if the user types in:
http://secure.myultratrust.com

then it should be a 301 forward to:
https://secure.myultratrust.com/diy/login/login.php

I found this page on stackexchange:
http://stackoverflow.com/questions/4933001/permanent-redirect-from-http-to-https-page

So I tried this but it doesn't work:
RewriteCond %{HTTPS} !ON
RewriteCond ${REQUEST_URI} ^index.php
RewriteRule ^(.*) https://secure.myultratrust.com/diy/login/login.php [R=301, L]

Open in new window


How can I get it to do a 301 redirect to
https://secure.myultratrust.com/diy/login/login.php

when the user goes to the insecure
secure.myultratrust.com
?

Thank you and Father God bless<><,
Victor
0
I am using Ampps on mac, I see if I place forwarding slash either in patternurl or in target url , in any case it does not work

#no 404 error with below line if there is no forwarding slash with any pattern
RewriteRule ^main/(.*)$ index.php?term=$1 [L]
#but 404 error with any of these two
RewriteRule ^main/(.*)$ /index.php?term=$1 [L]
RewriteRule ^/main/(.*)$ index.php?term=$1 [L]
#and more surprise, if I place any forwarding slash in any pattern but use "RewriteBase /" does not work in this case too , below with error:
RewriteBase /
RewriteRule ^main/(.*)$ index.php?term=$1 [L]


though I found lot of examples over internet using forwarding slashes , I do not know whats going wrong , but again I am surprised when I run wordpress on localserver (AMPPS) , I check its htaccess file as below:


RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

I see /index.php works here (there is no 404 error at all), what I am doing wrong.
0
I want to understand how cookies crumble with rewriterules
example below:

RewriteEngine On
RewriteRule ^index\.php - [CO=frontdoor:yes:.example.com:1440:/]
1.
if I resides .htaccess file with the code into the root directory e.g. http://localhost/ (or Applications/AMPPS/www) and access http://localhost/index.php with following code :

<?php
session_start();

echo $_SESSION['frontdoor'];

if(!isset($_COOKIE['frontdoor'])) {
    echo "Cookie named '" . $cookie_name . "' is not set!";
} else {
    echo "Cookie '" . $cookie_name . "' is set!<br>";
    echo "Value is: " . $_COOKIE[$cookie_name];
}
?>

I do not see any cookie named frontdoor ,

2. if I change domain name .example.com with localhost ? though no luck yet ,
I found very little documentation about it over internet , http://httpd.apache.org/docs/2.4/rewrite/flags.html seems a bit too little .
0
Hello, I have a wamp server running and my conf/extra/httpd-vhosts.conf configuration is as follows;

On my httpd.conf
# Virtual hosts
Include conf/extra/httpd-vhosts.conf

On my c:\xampp\apache\conf\extra\httpd-vhost.conf
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at 
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
##NameVirtualHost *:80

# for localhost to work properly
<VirtualHost *:80>
    DocumentRoot "c:\wamp\www"
    ServerName localhost
    ServerAlias localhost
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" common
    <Directory  "c:/wamp/www">
        AllowOverride All
        Options Indexes FollowSymLinks
        Require local
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "c:\wamp\www\folder01"
    ServerName demo.re-web.com
    ServerAlias demo.re-web.com
    ErrorLog "logs/mysite-error.log"
    CustomLog "logs/mysite-access.log" common
    <Directory  "c:\wamp\www\dds">
        AllowOverride All
        

Open in new window

0
I want to know if this is possible to have 2 way SSL with tomcat acting as client to websphere server. I have configured key and trust store correctly in server.xml of tomcat and enabled SSL on both tomcat and Websphere.

My problem is : when challenged by websphere server to present client certificate , tomcat does not present a client certificate.

I know that SSL is configured correctly in tomcat as when I open a servlet hosted on tomcat in Internet explorer, tomcat does present its server certificate.
When this servlet internally call web service hosted on websphere server, websphere server presents its server certificate and demand tomcat client certificate which tomcat does not present thus causing  the SSL handshake failure.  

Thanks,
Satish
0

Apache Web Server

19K

Solutions

15K

Contributors

The Apache HTTP Server is a secure, efficient and extensible server that provides HTTP services in sync with the current HTTP standards. Typically Apache is run on a Unix-like operating system, but it is available for a wide variety of operating systems, including Linux, Novell NetWare, Mac OS-X and Windows. Released under the Apache License, Apache is open-source software.