Java Beginner Packages in IntelliJ

I am currently attempting to edit a larger java project. After reading suggestions for how to get started, I decided to attempt to build the project first to play around with some of the code and see if I could get an understanding for the hierarchy of the project.

Unfortunately, I can't even seem to get past some of the basic issues such as missing package imports, and I'm not sure what is the best way to fix them. I currently set up my project on IntelliJ to pull from my git repo, and some packages are missing and display an error like:

import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.client.methods.CloseableHttpResponse; 
import org.apache.http.HttpEntity;

For each of these import statements, however, the http is underlined in red. I'm guessing this is a missing dependency? What would be the best way to resolve this?

if __name__ == main PHP to protect my code [duplicate]

This question already has an answer here:

I am somehow a noobie in PHP and I want to learn. I am making a proyect, in which I use require('parts/header.php') statements to include functions and templates. My pages look like this:

//This will check if the user is logged in and can see this page or not
//This loads the <head> tags and the header, including the navbar

<section id="mainArea">
    <h1>Hello <?php echo getUserNickname()?></h1>
    <p>Some stuff</p>

//This loads the <head> tags and the header, including the navbar

The problem is if someone enters he would see the top part, and that file is going to be executed. I don't want that. I was thinking doing some stuff in a .htaccess file like:

 #.htaccess inside parts directory

But I don't know how without affecting the server side code. Another alternative is to use the equivalent of if __name__ == 'main': of python, and do like:

 if(__name__ == 'main'){
     header('Location: /index.php');

What could I do?

.htaccess redirect any domain/directory to www.domain/directory [duplicate]

I'd like to use .htaccess to redirect any non-www domain to its www equivalent, regardless of directory - I assume I need multiple RewriteRules


domain.tld -> www.domain.tld
www.domain.tld -> www.domain.tld
domain.tld/directory -> www.domain.tld/directory
www.domain.tld -> www.domain.tld/directory

So far I have

RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

... but all that does is redirect domain.tld -> www.domain.tld. It does not account for a directory. That is, domain.tld/directory does not redirect to www.domain.tld/directory; it just goes directly to domain.tld/directory

Perhaps I need a separate rewrite rule? I'm cool with that.

Any help is greatly appreciated

Magento Duplicate Content Issue .htaccess rewrite 301 forwarding

i have some issues with duplicate content on my website. in the past i had diverse stores setup and i disabled them but the urls seem to exist still. i would like to set up a forwarding rule example:

now i have 2 product pages:

i would like to setup now that ?___store=tienda will always be redirected to original url. i have checked the ?___store=tienda product page holds the canonical link rel= canonical href= but i would like to get rid of them as i have tons of them showing up in google webmaster tools.

same happens to my integrated blog in magento with the fishpig extension, i write blog articles and it seems that it creates duplicate content with the same url structure:

Ideally i wish to create a rule in .htaccess file, what i could do already was to redirect all links from ?___store=tienda to home page adding following in .htaccess file

RewriteEngine On

RewriteCond %{THE_REQUEST} \?___store=tienda

RewriteRule ^(.*)$ /$1? [L,R=301]

source: Rewriting all url's with a question mark

Apache2/PHP Silex App not sending response

I'm developing a Silex PHP Application with an AngularJS frontend. I will intermittently revive a ERR_EMPTY_RESPONSE from Apache, no response headers, just nothing. Usually I just re-request and it loads fine. The odd part to me is that the request doesn't even look to be hitting the Apache access log. The other requests all show in the access log and there isn't anything in the error logs (set to LogLevel debug) that seem to suggest an issue. The issue isn't isolated to the angular requests either. If I loop on a curl request, every once in awhile it will return the same empty response.

The apache config file I'm using for this site is almost an exact copy of another site's, which doesn't seem to have this same issue. Really I'm not even sure where to start debugging at a deeper level than I already have. I'm working off the same code, and nearly the same config as a team-member, so my initial suspicion is that it's an apache module that I have enabled and he doesn't, other than reinstalling I'm not sure how to check into that.

Laravel – how to add routes if public server url includes path

I have a problem defining routes for my application, if the application is accessibly via a server url that contains a path.

I want /to be the Application (Laravel project), while /_api is a Lumen project, defining a RESTful API

I have an Apache server configuration as follows:

    ... # config for

    Alias /_api ".../api/public"
    <Directory ".../api/public">
</VirtualHost> is a lumen project.

$app->get('/_api'... - this works, if I request

$app->get('/_api/messages'... - I get an Exception if I request NotFoundHttpException in RouteCollection.php

Redirect only with specific domain

I have a website with 2 different domains, for example:

Now i want, that every user coming from should be redirected to

Ill tried:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^example\.com$
RewriteRule ^.*$$0 [L,QSA,R=301]

But now still all users from get redirected to

How can i solve that, that only users from gets redirected (also with all subfolders).


Subdomain redirecting to main domain without virtualhost

I have a site setup in apache with virtualhosts on port 80 and 443 (see configs below). In fact those are the only 2 virtualhosts at all on the server.

However, when I navigate to, the browser is redirecting to, and even finds the correct document root and renders the login page of sub.example.come, where it then gets an ssl error since I only have a certificate for

The first thing I tried was to redirect back to I first tried with .htaccess with the Rewrite directives, and it seemed to have no effect. Then I tried setting a permanent redirect in the apache config file, but this resulted in a redirection loop.

How can be redirecting to, and further, how could be finding the document root at all?

Ideally, shouldn't exist at all, but I'd be satisfied with it at least redirecting to

Here is my apache configuration. (Using ubuntu 12.04 and apache 2.2)


NameVirtualHost xx.xx.xx.xx:80
NameVirtualHost xx.xx.xx.xx:443

Listen 80

<IfModule mod_ssl.c>
    Listen 443

<IfModule mod_gnutls.c>
    Listen 443

virtualhosts configuration

# redirect to https
<VirtualHost xx.xx.xx.xx:80>
    DocumentRoot /var/www/path/to/webroot
    RedirectPermanent /

# https
<VirtualHost xx.xx.xx.xx:443>

    DocumentRoot /var/www/path/to/webroot

    <Directory />
        Options FollowSymLinks
        AllowOverride None

    <Directory /var/www/path/to/webroot>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all

    SSLEngine on
    SSLCertificateFile    /etc/apache2/ssl/
    SSLCertificateKeyFile /etc/apache2/ssl/
    SSLCertificateChainFile /etc/apache2/ssl/chain.crt

    LogLevel notice
    ErrorLog ${APACHE_LOG_DIR}/sub-example-error.log
    CustomLog ${APACHE_LOG_DIR}/sub-example-access.log combined

Proxy server: intercept requests

I would like to set up a proxy so that I can intercept requests from my iPhone (for instance, a search to Google), parse the request, and then create a new request (for instance, a search on Yahoo! with the same term). Can this be done with an Apache server? How can I set this configuration up?

nginx config – from htacces to nginx – error

I have a problem with nginx configuration. I came from apache and i don't know to configure nginx to work, please help. My htaccess file is

<Files ~ "^\.(htaccess|htpasswd)$">
deny from all

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([a-zA-Z0-9]{2})/?$  /index.php?route=page&action=index&lang=$1 [NC]
RewriteRule ^admin/([a-z_]+)/([a-z_]+) /index.php?route=admin&user=$1&action=$2 [NC]
RewriteRule ^admin /index.php?route=admin&user=ferdis&action=index [NC]
RewriteRule ^([a-z0-9_-]+)/ch/([a-z0-9_-]+) /index.php?route=page&action=$2 [NC]
RewriteRule ^requests /index.php?route=action&%{QUERY_STRING} [NC]
RewriteRule ^user /index.php?route=page&action=user [NC]
RewriteRule ^favorites /index.php?route=page&action=favorites [NC]
RewriteRule ^register /index.php?route=page&action=register [NC] 
RewriteRule ^forgot /index.php?route=page&action=forgot [NC] 

RewriteCond %{HTTP_HOST} ^(domain\.com)(:80)? [NC]
RewriteRule ^(.*)$1 [R=301,L]
order deny,allow

AddDefaultCharset UTF-8

and my nginx config is

server {
    listen 80;
    root /home/;
    access_log /var/log/nginx/ main buffer=512k;
    charset utf-8;
    override_charset  on;
    location / {
        if ($http_host ~* "^(domain\.com)(:80)?"){
            rewrite ^/(.*)$1 redirect;
        expires 7d;
        index index.php index.html index.htm;
        autoindex on;
        limit_rate_after 1m;
        limit_rate 100k;
        gzip on;
        try_files $uri $uri/ /index.php?$request_uri;
        rewrite "^/([a-zA-Z0-9]{2})/?$" /index.php?route=page&action=index&lang=$1;
        rewrite ^/([a-z0-9_-]+)/ch/([a-z0-9_-]+) /index.php?route=page&action=$2;
        rewrite ^/admin/([a-z_]+)/([a-z_]+) /index.php?route=admin&user=$1&action=$2;
        rewrite ^/admin /index.php?route=admin&user=ferdis&action=index;
        rewrite ^/requests /index.php?route=action&$query_string;
        rewrite ^/user /index.php?route=page&action=user;
        rewrite ^/favorites /index.php?route=page&action=favorites;
        rewrite ^/register /index.php?route=page&action=register;
        rewrite ^/forgot /index.php?route=page&action=forgot;

    location ~\.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param QUERY_STRING     $query_string;
        fastcgi_param REQUEST_METHOD   $request_method;
        fastcgi_param CONTENT_TYPE     $content_type;
        fastcgi_param CONTENT_LENGTH   $content_length;
        fastcgi_param GATEWAY_INTERFACE  CGI/1.1;
        fastcgi_param SERVER_SOFTWARE    nginx;
        fastcgi_param SCRIPT_NAME        $fastcgi_script_name;
        fastcgi_param REQUEST_URI        $request_uri;
        fastcgi_param DOCUMENT_URI       $document_uri;
        fastcgi_param DOCUMENT_ROOT      $document_root;
        fastcgi_param SERVER_PROTOCOL    $server_protocol;
        fastcgi_param REMOTE_ADDR        $remote_addr;
        fastcgi_param REMOTE_PORT        $remote_port;
        fastcgi_param SERVER_ADDR        $server_addr;
        fastcgi_param SERVER_PORT        $server_port;
        fastcgi_param SERVER_NAME        $server_name;
        fastcgi_param PATH_INFO $fastcgi_script_name;
        expires off;

    include /etc/nginx/mime.types;
#        error_page  404 500 502 503 504              /index.html;

My website is working, but only index page. If I'm trying to get another page is not working good.