How to force SSL on a specific file example.org/index.html?

I have a php based website....i trying to use ssl...the ssl is working fine in site, the problem is it not redirect with https....it only show http and i try to edit in .htaccess file, but its not working.... also my site open with this format example.org/index.html with /index.html

i trying to use this, but not working

RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301] 

.htaccess code:

RewriteEngine On    
RewriteBase /
#AuthUserFile /home/products/html/path/.htpasswd
#AuthGroupFile /dev/null
#AuthName "Private Area"
#AuthType Basic
#<Limit GET POST>
#require valid-user
#</Limit>

<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
    FileETag None
    <IfModule mod_headers.c>
    Header unset ETag
    Header set Cache-Control "max-age=31536000, Public"
    </IfModule>
</FilesMatch>

Options -Indexes

RewriteCond  %{REQUEST_FILENAME}  !-f

RewriteRule ^(.+).html$ $1/?%{QUERY_STRING}

-------urls---------

RewriteRule ^index/$ path/index.php
RewriteRule ^index/([^\/]+)/$ path/index.php?list=$1&%{QUERY_STRING}

can I use ServerAlias * on apache

We need to have our apache server send all domains pointed with a dns cname entry to resolve to one root folder. Can I use ServerAlias * ?

Something like this:

<VirtualHost 111.11.11.111:80>
    ServerName the.domain-the-cname-points-to.com
    ServerAlias *
    DocumentRoot /home/theuser/public_html/FRLUsers
    ServerAdmin [email protected]
</VirtualHost>

Also the auto generated httpd.conf virtual host entries have:

UseCanonicalName Off

UserDir disabled

UserDir enabled theuser

They also have some other entries. A complete record looks like this:

<VirtualHost 111.11.11.111:80>
    ServerName the.domain-the-cname-points-to.com
    ServerAlias *
    DocumentRoot /home/theuser/public_html/FRLUsers
    ServerAdmin [email protected]
    UseCanonicalName Off

    ## User theuser # Needed for Cpanel::ApacheConf
    UserDir disabled
    UserDir enabled theuser

    # Enable backwards compatible Server Side Include expression parser for     Apache versions >= 2.4.
    # To selectively use the newer Apache 2.4 expression parser, disable     SSILegacyExprParser in
    # the user's .htaccess file.  For more information, please read:
    #        http://httpd.apache.org/docs/2.4/mod/mod_include.html#ssilegacyexprparser
    <IfModule mod_include.c>
        <Directory "/home/theuser/public_html/FRLUsers">
            SSILegacyExprParser On
    </Directory>
    </IfModule>

    <IfModule mod_suphp.c>
        suPHP_UserGroup theuser theuser
    </IfModule>
    <IfModule concurrent_php.c>
        php4_admin_value open_basedir     "/home/theuser:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4    /lib/php:/tmp"
        php5_admin_value open_basedir     "/home/theuser:/usr/lib/php:/usr/local/lib/php:/tmp"

    </IfModule>
    <IfModule !concurrent_php.c>
        <IfModule mod_php4.c>
            php_admin_value open_basedir     "/home/theuser:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4    /lib/php:/tmp"
        </IfModule>
        <IfModule mod_php5.c>
            php_admin_value open_basedir     "/home/theuser:/usr/lib/php:/usr/local/lib/php:/tmp"
        </IfModule>
        <IfModule sapi_apache2.c>
            php_admin_value open_basedir     "/home/theuser:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4    /lib/php:/tmp"
    </IfModule>
    </IfModule>
    <IfModule !mod_disable_suexec.c>
        <IfModule !mod_ruid2.c>
            SuexecUserGroup theuser theuser
        </IfModule>
    </IfModule>
    <IfModule mod_ruid2.c>
        RMode config
        RUidGid theuser theuser
    </IfModule>
    <IfModule itk.c>
        # For more information on MPM ITK, please read:
        #   http://mpm-itk.sesse.net/
        AssignUserID theuser theuser
    </IfModule>

    ScriptAlias /cgi-bin/ /home/theuser/public_html/FRLUsers/cgi-bin/




    # To customize this VirtualHost use an include file at the following     location
    # Include         "/usr/local/apache/conf/userdata/std/2_4/theuser/rebrand.getseobot.com/*.conf"
</VirtualHost>

Do I need to create an include file? Do I need the other modrewrites and includes?

Any help would be appreciated.

.htaccess rewrite based on referrer

I'd like to direct all traffic coming from a particular domain (foo.net) to the homepage of my website (http://www.bar.net/index.php). I've tried many, many ways of doing this, some of which crash the site, others of which simply don't work. However, I can now reliably get it to direct to google.com or bbc.com using the following:

<IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine on
  RewriteCond %{HTTP_REFERER} ^http://(www\.)?foo\.net
  RewriteRule ^$ http://www.bbc.com [L]
</IfModule>

This is the current code:

<IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine on
  RewriteCond %{HTTP_REFERER} ^http://(www\.)?foo\.net
  RewriteRule ^$ http://www.bar.net/index.php [L]
</IfModule>

However, nearly all the traffic comes via one link to a particular page on my site http://www.bar.net/?q=en/tickets and when I redirect to my own homepage, ?q=en/tickets is always appended to the URL and the visitor is sent to the tickets page anyway (the URL looks like this: http://www.bar.net/index.php?q=en/tickets

It's a Drupal site so the .htaccess has other content, and I've put this right at the beginning of the .htaccess. I feel I just need to tweak something here - any ideas

301 RedirectMatch – Issue

I posted a question here which I got an answer for, but now I've identified an issue with the code.

Original Question:

301 RedirectMatch - Many URLs

RewriteRule ^([^-]+)-([^-]+)-(?!in)([^/]+)-([^-]{2})\.html$ /$1-$2-in-$3-$4.html [R=301,L]
RewriteRule ^([^-]+)-([^-]+)-(?!in)([^/]+)\.html$ /$1-$2-in-$3.html [R=301,L]

While the above fixed all the issues with the URLs, I noticed my normal URLs are having issues. Example, domain.com/careers-jobs-music-degree.html is turning into domain.com/careers-jobs-in-music-degree.html - the 'in' is being added to other URLs that don't have 'music-classes' in the URL. Is there any way to prevent this?

Thanks!

blocking direct url access to protected files

I have been creating a CMS for some time now and about the only thing I have trouble with really is htaccess files never had much experience with them for the most part.

I am trying to safe guard files from direct urls (hotlinking, downloading, executing etc) So I've placed this htaccess in every subfolder of my CMS main folder.

#To block direct browser urls to get your protected files
Order Deny,Allow
Deny from all

It works for the most part but I was wondering if there were any other precautions that I could take? For instance I have a folder called assets which contains CSS,JS,and images that are needed for the CMS admin panel. Though I can't place this .htaccess file in that folder or the browser can't download them. So which action could I take so no direct access to allowed to files such as CSS. For example the url would look something like this mysite.com/cms-branch/assets/css/main.css The only reason I want safe guards is so that none of my later clients are weary of hotlinking or anyone getting into their files. I have good algorithms in place for signing into the CMS, as well as a TID to gain access with one account at a time from one IP address. Anyways any more .htaccess tricks out there to allow my site or a clients site to download these files but not someone else?

As umka has stated as a possible duplicate, before I go any further I'm not sure what it all means so could someone explain what this does, I'm not a copy and paste type of guy, I'd like to learn the language and understand what I am doing before using it.

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain\.com [NC]
RewriteRule \.(gif|jpe?g|js|css)$ - [F,NC,L]

Open filehandler not working under mod_perl ModPerl::PerlRun

I'm at my first attempt to use mod_perl, i'm totally new to it. I opted for PerlRun 'cause i don't want to make any modification to the scripts i already have, followed the instructions here:

http://41j.com/blog/2012/09/installing-apache2modperl-on-ubuntu-12-04/

So i uploaded script.pl to /perl and the script looks like to be running fine except this:

open(my $fh, '<:encoding(UTF-8)', 'page_template.htm') or die $!;

It won't open the file and will die "No such file or directory at /var/www/perl/script.pl"

Of course script.pl do exist.

.htaccess remove trailing slash – should be simple?

So I have the following .htaccess file in one of my folders (public):

<IfModule mod_rewrite.c>
  <IfModule mod_negotiation.c>
    Options -MultiViews
  </IfModule>

  RewriteEngine On

  # Redirect Trailing Slashes...
  RewriteRule ^(.*)/$ /$1 [L,R=301]
</IfModule>

I need http://localhost/eamorr.com/lv/public/about/

to redirect to:

http://localhost/eamorr.com/lv/public/about (i.e. trailing slash removed)

But what I'm getting is as follows:

http://localhost/eamorr.com/lv/public/about/

redirects to:

http://localhost/about

(the trailing slash got removed OK, but the path is now wrong!!!)

Can any Apache2 experts suggest anything? I find these redirect rules to be too terse for my understanding.

Here's the complete .htaccess file (nothing else in this file):

<IfModule mod_rewrite.c>
  <IfModule mod_negotiation.c>
    Options -MultiViews
  </IfModule>

  RewriteEngine On

  DirectorySlash Off

  # Redirect Trailing Slashes...
  RewriteRule ^(.*)/$ /$1 [R=302]
  ###RewriteRule ^(.*)/$ /$1 [L,R=302]

  # Handle Front Controller...
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^ index.php [L]
</IfModule>

The resource path [cxf-ehcache.xml] is not valid

I'm trying to implement message-level encryption. Specifically, the body of the SOAP message will be encrypted. I'm trying encrypt the traffic from the client to the web service.

The client sends the encrypted data successfully:

UTF-8
Content-Type: text/xml
Headers: {Accept=[*/*], SOAPAction=[""]}
Payload: <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" soap:mustUnderstand="1">
      <xenc:EncryptedKey xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" Id="EK-2F22184B9EAAC6244514331031642721">
        <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"/>
        <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
          <wsse:SecurityTokenReference>
            <ds:X509Data>
              <ds:X509IssuerSerial>
                <ds:X509IssuerName>CN=testkey</ds:X509IssuerName>
                <ds:X509SerialNumber>1940918168</ds:X509SerialNumber>
              </ds:X509IssuerSerial>
            </ds:X509Data>
          </wsse:SecurityTokenReference>
        </ds:KeyInfo>
        <xenc:CipherData>
          <xenc:CipherValue>n6hH/RHguV2YCqZxI2Sq+X6hnaDm/OSUJsNRvcsxEHZw6lpdR+JitcbEfdv2huhsQ0HbtGjj0dfOa9pOCiwuaZW5wdR2Nq8kq85lZ4g2l/rHkGBRch19/P2oT0wXHIh/qQRHSqDhBg4bUrLKlzw+mA/H8SZimFvUz5xymwzKaQcv8puc0r9yKukQRmKVCjiS7enBznN0PdAfoitKdJYIm44/UaXa+CLwySPAw1cHpETAWoKclMqtL8Wgs9cN8+aYCmbC8kSDS+DURXMWc8ilVcirrYVrPAyEVZIX/NE9Pe8SIQmfgD5GHdFaIOPYcmf0i1w4/YQdTxzCFIXlwNkI0w==</xenc:CipherValue>
        </xenc:CipherData>
        <xenc:ReferenceList>
          <xenc:DataReference URI="#ED-2F22184B9EAAC6244514331031642892"/>
        </xenc:ReferenceList>
      </xenc:EncryptedKey>
    </wsse:Security>
  </SOAP-ENV:Header>
  <soap:Body>
    <xenc:EncryptedData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" Id="ED-2F22184B9EAAC6244514331031642892" Type="http://www.w3.org/2001/04/xmlenc#Content">
      <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/>
      <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
        <wsse:SecurityTokenReference xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsse11="http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd" wsse11:TokenType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKey">
          <wsse:Reference URI="#EK-2F22184B9EAAC6244514331031642721"/>
        </wsse:SecurityTokenReference>
      </ds:KeyInfo>
      <xenc:CipherData>
        <xenc:CipherValue>PNHM0fKuMOHtpm0rGSpR0siGeiFRz/4Dwgwauwe2C6usChfH5a7PDXimplOvYSKE9d8zTNXie3tDMfprHLS/hPD0vABlSGA4haGMYrelFKNgAU8BhXbBfrQimD7e8ue6gV/BBwAGa0rgoExPYJQh0w==</xenc:CipherValue>
      </xenc:CipherData>
    </xenc:EncryptedData>
  </soap:Body>
</soap:Envelope>

But the web service response is bad:
NFORMACIÓN: Inbound Message
----------------------------
ID: 1
Response-Code: 500
Encoding: UTF-8
Content-Type: text/xml;charset=UTF-8
Headers: {connection=[close], content-type=[text/xml;charset=UTF-8], Date=[Sun, 31 May 2015 20:12:44 GMT], Server=[Apache-Coyote/1.1], transfer-encoding=[chunked]}
Payload: <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <soap:Fault>
      <faultcode>soap:Server</faultcode>
      <faultstring>The resource path [cxf-ehcache.xml] is not valid</faultstring>
    </soap:Fault>
  </soap:Body>
</soap:Envelope>

--------------------------------------
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: The resource path [cxf-ehcache.xml] is not valid
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:158)
    at com.sun.proxy.$Proxy37.factorial(Unknown Source)
    at com.mathutility.test.TestMathUtility.main(TestMathUtility.java:57)
Caused by: org.apache.cxf.binding.soap.SoapFault: The resource path [cxf-ehcache.xml] is not valid

I am using: Apache Tomcat 8 and Apache CXF 2.6.13

contact form 7 upload attachment file to form

I wish to upload a file so it can be attached to the mail message sent from the contact form.

I followed the instructions:

file-uploading-and-attachment

The file is never attached. The only things that gets in the mail message is its name.

I have modified uploads and wpcf7_uploads folders both to 777 Although, the file does not get uploaded to the server.

What I did notice is that every time a file is uploaded, the system or the script for uploading recreates an htaccess file with Deny from all. Yes it sounds wild!!! Any ideas as for how to resolve this?? I tried removing htaccess, commenting the line, renaming the file... But every upload I try the (I guess) folder gets recreated with the new htaccess-Deny from all....

Thank you

Only rewrite when domain only

I want to only write the domain then the domian itself it requested and not to rewrite when there are any subdirectories.

So when accessing

example.com

you sent to

example.com/fr

but when you go to

example.com/albums

you get taken to

example.com/albums

not

example.com/fr/albums

which is what is happening with

RewriteCond %{HTTP_HOST} ^www.example.fr [NC]
RewriteRule ^(.*)$ http://www.example.fr/fr/$1 [L,R=301,NC]