.htaccess with php action get

i want to do something in .htaccesde for example there is a product and form like

<form method="GET" action="search">  
<input name="color" type="text" />
<input name="size" type="text" />
<button type="submit"> search </button>
</form>

when i submit it i have a link like http://website.com/search?color=blue&size=small

i wanna use it in switch case like ;

$page = GET("page");
Switch($page){
    case "search": 
        if($color = $_GET["color"] && $size = $_GET["size"]){ 
            require THEMES."/inc/search.php";   
        }else{ 
            something..  
        } 
        break;   
}

so how can i do it with .htaccess ?

Pretty URLS for ErrorDocument, Need advice with my rewrite rules

My Goal

When someone visits my page and some error happens, no matter the code, they see a url similar to this

https://example.com/403

My Rewrite rules for accomplishing this

RewriteRule ^([4|5][0-9][0-9])$ /error.php?errorcode=$1 [L,R]
ErrorDocument 403 /403

Whats happening

So when i visit say, https://example.com/.htaccess, i would expect it to go to https://example.com/403 but instead it goes to https://example.com/error.php?errorcode=403

Can anyone offer me any guidance in what i need to do to accomplish what i want it to look like? Not only do i want to fix this but i'd like to learn what I was doing wrong.

What are these TCP ports opened by Apache Tomcat?

When I start Tomcat I see the following using netstat (filtered by tomcat PID):

TCP    0.0.0.0:5007           xxxx34793KZ:0          LISTENING
TCP    0.0.0.0:8081           xxxx34793KZ:0          LISTENING
TCP    0.0.0.0:8543           xxxx34793KZ:0          LISTENING
TCP    127.0.0.1:8005         xxxx34793KZ:0          LISTENING
TCP    127.0.0.1:29821        xxxx34793KZ:29822      ESTABLISHED
TCP    127.0.0.1:29822        xxxx34793KZ:29821      ESTABLISHED
TCP    127.0.0.1:29823        xxxx34793KZ:29824      ESTABLISHED
TCP    127.0.0.1:29824        xxxx34793KZ:29823      ESTABLISHED
TCP    127.0.0.1:29830        xxxx34793KZ:29831      ESTABLISHED
TCP    127.0.0.1:29831        xxxx34793KZ:29830      ESTABLISHED
TCP    127.0.0.1:29832        xxxx34793KZ:29833      ESTABLISHED
TCP    127.0.0.1:29833        xxxx34793KZ:29832      ESTABLISHED
TCP    127.0.0.1:29834        xxxx34793KZ:29835      ESTABLISHED
TCP    127.0.0.1:29835        xxxx34793KZ:29834      ESTABLISHED
TCP    127.0.0.1:29836        xxxx34793KZ:29837      ESTABLISHED
TCP    127.0.0.1:29837        xxxx34793KZ:29836      ESTABLISHED
TCP    [::]:8081              xxxx34793KZ:0          LISTENING
TCP    [::]:8543              xxxx34793KZ:0          LISTENING

Ports 29821-29824 and 29830-29837 are what I'm wondering about.

I have searched the web, tomcat documentation, tomcat source code and any mailing list I can think of (including Stackoverflow) and can find nothing on the purpose of these TCP ports. They come in pairs which implies to me that they are possibly configured to loopback. I'm stumped as to why Tomcat needs these.

Our application that runs on Tomcat gets installed into environments where IT Security is quite robust, so they want to know the reason for every port in use.

Any ideas?

SVG images not displaying in browser, result of server?

I'm displaying SVG images with two methods on a website, css background and tag, neither of which are working. However, I'm able to load svg files via the method, but this doesn't work for this case (it could replace but not background images). Because someone will ask, the SVG files are there, and they are accessible if you go to their url directly.

I've been testing and working with this site on a separate, private server and the SVG images were displaying properly there. This leads me to believe that the issue is a result of something server-side.

I've tried adding the following to the .htaccess file, but it didn't fix anything:

AddType image/svg xml svg svgz 
AddEncoding gzip svgz

I'm aware of some alternative methods that involve httpd.conf, but I don't have access to this.

Here's the troublesome site: http://www.focusvitamins.com/get-started/

Here's the working test site: http://focus.steadfa.st/dtclanding2015/

Thanks for the help!

Flask – Apache Internal Server Error without log entry

I built a webapp using the flask framework, sqlalchemy and sqlite and recently deployed it on a VPS. It works perfectly for the cover page and the legal page, however I get a "500 Internal Server Error" when trying to open the blog page. I guess it must have something to do with the fact that the function I wrote, used by flask to serve the blog page uses database queries, whereas the other (working) pages do not. The weird thing is however, that the blog page loads correctly when I visit it the first time after executing "apachectl restart" on my VPS. When I click the link again, I get the "500 Internal Server error" error page. I looked at the log (/var/log/apache2/error.log), but there is no information/error in that file. I tried setting the LogLevel of the Apache server to debug, but that doesn't help, either. I use absolute paths to my database in both scripts containing database queries as suggested in other threads on stackoverflow. I also did some research on this error but didn't find any useful information.

The webserver.py file:

from flask import Flask, render_template, url_for, request, redirect, flash
from sqlalchemy import create_engine, desc
from sqlalchemy.orm import sessionmaker
from database_setup import Base, Entry, Comment

app = Flask(__name__)

engine = create_engine('sqlite:////var/www/homepage/blog.db')
Base.metadata.bind = engine
DBSession = sessionmaker(bind = engine)
session = DBSession()

# Obviously just a temporary password, change later!
app.secret_key = ''

@app.route('/')
@app.route('/home')
@app.route('/index')
@app.route('/home.html')
@app.route('/index.html')
def index():
    return render_template('index.html')

@app.route('/legal')
@app.route('/legal.html')
def legal():
    return render_template('legal.html')

@app.route('/blog')
@app.route('/blog.html')
def blog():
    # Fetch all entrys from database in correct chronological order (newest first)
    entrys = session.query(Entry).order_by(desc(Entry.timestamp)).all()

    return render_template('blog.html', blog_entrys = entrys)

@app.route('/comment/<int:entry_id>', methods=['GET', 'POST'])
def comment(entry_id):
    if request.method == 'GET':
        entry = session.query(Entry).filter(Entry.id == entry_id).first()
        _path = request.path

        if not entry:
            flash('Unknown blog-post ID')
            return render_template('blog.html')

        return render_template('comment.html', blog_entry = entry, path = _path)
    elif request.method == 'POST':
        name = request.form['name']
        comment = request.form['comment']

        if name == '':
            flash('Please fill in your name')
            return redirect(url_for('comment'))
        if comment == '':
            flash('Comment text cannot be empty')
            return redirect(url_for('comment'))

        new_comment = Comment(entry_id = entry_id, text = comment, name = name)
        session.add(new_comment)
        session.commit()

        return redirect(url_for('blog'))
    else:
        flash('Bad request')
        return redirect(url_for('index'))

if __name__ == '__main__':
    app.debug = True
    app.run(host = 'localhost', port = 5000)

The database_setup.py file:

from sqlalchemy import Table, Column, ForeignKey, Integer, String, Boolean, DateTime
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
from sqlalchemy import create_engine

Base = declarative_base()


class Entry(Base):
    __tablename__ = 'entry'

    id = Column(Integer, primary_key = True)

    title = Column(String(100), nullable = False)
    body = Column(String, nullable = False)
    timestamp = Column(DateTime, nullable = False)
    featured = Column(Boolean, nullable = False)

    comments = relationship('Comment')

    def is_featured(self):
        return self.featured


class Comment(Base):
    __tablename__ = 'comment'

    id = Column(Integer, primary_key = True)
    entry_id = Column(Integer, ForeignKey('entry.id'))

    text = Column(String(500), nullable = False)
    name = Column(String(80))


engine = create_engine('sqlite:////var/www/homepage/blog.db')
Base.metadata.create_all(engine)

The Apache error log:

[Tue

 Dec 01 02:33:45 2015] [error] python_init: Python version mismatch, expected '2.6.5+', found '2.6.6'.
[Tue Dec 01 02:33:45 2015] [error] python_init: Python executable found '/usr/bin/python'.
[Tue Dec 01 02:33:45 2015] [error] python_init: Python path being used '/usr/lib/python2.6/:/usr/lib/python2.6/plat-linux2:/usr/lib/python2.6/lib-tk:/usr/lib/python2.6/lib-old:/usr/lib/python2.6/lib-dynload'.
[Tue Dec 01 02:33:45 2015] [notice] mod_python: Creating 8 session mutexes based on 10 max processes and 0 max threads.
[Tue Dec 01 02:33:45 2015] [notice] mod_python: using mutex_directory /tmp 
[Tue Dec 01 02:33:45 2015] [debug] mod_wsgi.c(9971): mod_wsgi (pid=7459): Socket for 'homepage' is '/var/run/apache2/wsgi.7459.42.1.sock'.
[Tue Dec 01 02:33:45 2015] [info] mod_wsgi (pid=9824): Starting process 'homepage' with uid=1000, gid=1000 and threads=5.
[Tue Dec 01 02:33:45 2015] [info] mod_wsgi (pid=9824): Attach interpreter ''.
[Tue Dec 01 02:33:45 2015] [notice] Apache/2.2.16 (Debian) mod_python/3.3.1 Python/2.6.6 mod_wsgi/3.3 configured -- resuming normal operations
[Tue Dec 01 02:33:45 2015] [info] Server built: Feb  1 2014 21:22:42
[Tue Dec 01 02:33:45 2015] [debug] prefork.c(1013): AcceptMutex: sysvsem (default: sysvsem)
[Tue Dec 01 02:33:45 2015] [info] mod_wsgi (pid=9832): Attach interpreter ''.
[Tue Dec 01 02:33:48 2015] [info] [client 31.19.64.54] mod_wsgi (pid=9824, process='homepage', application=''): Loading WSGI script '/var/www/homepage/homepage.wsgi'.
[Tue Dec 01 02:33:48 2015] [info] mod_wsgi (pid=9833): Attach interpreter ''.
[Tue Dec 01 02:33:48 2015] [debug] mod_deflate.c(615): [client 31.19.64.54] Zlib: Compressed 1132 to 618 : URL /blog.html
[Tue Dec 01 02:33:51 2015] [debug] mod_deflate.c(615): [client 31.19.64.54] Zlib: Compressed 291 to 200 : URL /blog.html

Is it better to use PHP built-in server or apache2 for Symfony2 dev environment [on hold]

What is the better approach for keep a long-term stable dev environment ?

Should I prefer use server:runor my apache2 server on app_dev.php for develop ?

Because I work on client side , I know how much use a non-fixed base url can be ambiguous and cause surprises in production, also I think it's more simple to use PHP built-in server, and it's easy for start/stop/restart.

But a collaborator said the opposite, because :

It's more a production-like environment, and it's more stable for long term development.

Symfony cookbook said :

The preferred way to develop your Symfony application is to use PHP's internal web server. However, when using an older PHP version or when running the application in the production environment, you'll need to use a fully-featured web server.

http://symfony.com/doc/current/cookbook/configuration/web_server_configuration.html

But what is the right way ?

EDIT: I do not ask for opinions but real facts and to know how to get more stability in my development workflow

So, my question is :

Which of these approaches will provide me with the closest dev environment from production ?

pyOpenSSL Cipher List vs Apache

In Apache, I'm successfully using the following OpenSSL cipher settings:

SSLHonorCipherOrder on
SSLCipherSuite "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM \
                EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 \
                EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 \
                EECDH EDH+aRSA \
                !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS !RC4"

I'm trying to emulate that in a python (Twisted) server, but the server won't serve any pages with a comparable cipher list specified. What am I doing wrong? Here's the python (well in essence...)

     from OpenSSL import SSL
....
     httpSslContext = ssl.DefaultOpenSSLContextFactory(...)
     ctx = httpSslContext.getContext()                
     ctx.set_options( SSL.OP_CIPHER_SERVER_PREFERENCE )                 
     ctx.set_cipher_list( "EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH:EDH+aRSA:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4" )   
...

It works if I change the cipher list to something simple like "RC4-SHA". I set some other options, e.g. the excepted protocols, but I don't know if that relevant...

Basic JSON Post method with single param is gets error 405 – Method not allowed

import com.sun.tools.javac.comp.Todo;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import java.util.ArrayList;
import java.util.List;

public class StockLevels {

    public static void main(String[] args) {

        //I need a routine to post and get hold of all that JSON,
        HttpClient httpClient = HttpClientBuilder.create().build();

        try {

            HttpPost request = new HttpPost([MyURL]);
            request.addHeader("Content-Type", "application/json");

            List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
            params.add(new BasicNameValuePair("key", "12345678"));
            request.setEntity(new UrlEncodedFormEntity(params));

            HttpResponse response = httpClient.execute(request);
            System.out.print(response.toString());

            String json = EntityUtils.toString(response.getEntity(), "UTF-8");
            try {
                JSONParser parser = new JSONParser();
                Object resultObject = parser.parse(json);

                if (resultObject instanceof JSONArray) {
                    JSONArray array = (JSONArray)resultObject;
                    for (Object object : array) {
                        JSONObject obj = (JSONObject)object;
                        System.out.println(obj.toString());
                    }
                }
            }
            catch(Exception e){
                //Todo handle exception
            }

            // handle response here...
        }catch (Exception ex) {
            // handle exception here
        } finally {
            httpClient.getConnectionManager().shutdown(); //Deprecated
        }
    }
}

I've been through several different tutorials online and from what I can see I've set up everything correct. The same url and params are working as expected in Postman (though only using raw json, not form-urlencoded if that matters). What have I missed?

Also, do I have to create a List, or is there some way to use a single parameter?

Redirecting wordpress to HTTPS

I have a .htaccess file generated by a plugin. It looks like this:

# BEGIN Far Future Expiration Plugin
<IfModule mod_expires.c>
ExpiresActive on
<FilesMatch "\.(gif|jpeg|jpg|png)$">
ExpiresDefault "access plus 168 hours"
</FilesMatch>
</IfModule>
# END Far Future Expiration Plugin

# 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

I need to implement a HTTPS redirection. I've tried adding the following to the file but it gives me a Too many redirects error.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.yoursite.com [NC]
RewriteRule ^(.*)$ https://www.yoursite.com/$1 [L,R=301,NC]

Any tips?