Using RewriteCond with %{REQUEST_URI} for mod_rewrite

I would like the URL:

http://domain.com/category/subcategory/title

To point to:

http://domain.com/posts/category/subcategory/title.php

My .htaccess file looks like this:

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{QUERY_STRING} !^.+
#RewriteCond post/%{REQUEST_URI}.php -f
RewriteRule ^(.*)$ post/$1.php [L]

This works however when I uncomment the line above it does not work.

I have tried:

RewriteCond /post/%{REQUEST_URI}.php -f
RewriteCond post/%{REQUEST_URI}.php -f
RewriteCond post%{REQUEST_URI}.php -f

None of these work. What am I doing wrong?

Also is there an easy way to debug these rules? Like console logging variables or something?

What is the right way to configure Apache to serve a project over a local network

I have my project running in an apache virtual host. the name of the conf file is btapp.local.conf this is the content of the file

<VirtualHost *:80>
ServerName btapp.local
DocumentRoot /var/www/btapp/app/webroot


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

My local network IP is addr:192.168.3.218 But when i am trying to access the project from the network by 192.168.3.218/btapp.local I am getting the error The requested URL /btapp.local was not found on this server. As of now, I have edited my 000-default.conf and put the content of btapp.local.conf (basically i have pointed default host to the path of the project) I want to know the follwing things
1.Is this the right way to serve a project over the network?
2.Are there other ways that I can use to serve the project through the network without modifying the 000-default.conf file?

EDIT this is my /etc/hosts file content

127.0.0.1 localhost
127.0.1.1 bonnie
127.0.1.1 btapp.local

Issue while creating JIRA connection using Apache CXF library

I am working on Jira. I am creating a issue in Jira using rest api by making use of Jersey libraries. However I want to integrate my Jira code to apache cxf karaf but the problem is that jersey libraries is not compitable with apache cxf. I have used a following code to create a jira connection.

public String jiraConnectionpost(String auth, String url, String key) throws JSONException {

    Client client = Client.create();
    System.out.println("Inside jiraConnectionpost for JiraAdapterImpl");

    WebResource webResource = client.resource(url);
    ClientResponse response = webResource.header("Authorization", "Basic " + auth).type("application/json")
            .accept("application/json").post(ClientResponse.class, key);
    int statusCode = response.getStatus();

    if (statusCode == 401) {
        try {
            throw new AuthenticationException("Invalid Username or Password");
        } catch (AuthenticationException e) {
            e.printStackTrace();
        }
    }
    String jsonString = response.getEntity(String.class);
    url = null;
    return jsonString;
}

But the Client, WebResource, ClientResponse are making use of Jersey jars to establish a connection.

Is there any possible way that we can create jira connection by making use of cxf jars or else is there any way by which we can integrate my jira connection to apache cxf application. Whenever I add Jersey jars to my pom.xml my karaf appliction doesn't work.

[email protected]()> list
START LEVEL 100 , List Threshold: 50
ID | State  | Lvl | Version        | Name
--------------------------------------------------------------
102 | Active |  80 | 1.1.1          | geronimo-jms_1.1_spec
106 | Active |  80 | 2.0.13         | Apache MINA Core
174 | Active |  80 | 20160212.0.0   | JSON in Java
193 | Installed|  80 | 1.0.0.SNAPSHOT | Chapter 5 :: Recipe 2 ::

Here Chapter 5 :: Recipe 2 :: is a jar which I am deploying to my karaf cointainer. Here its showing as installed but it has to be active if karaf has to work. When Jersey jars are removed it shows in active state.

[email protected]()> list
START LEVEL 100 , List Threshold: 50
ID | State  | Lvl | Version        | Name
--------------------------------------------------------------
102 | Active |  80 | 1.1.1          | geronimo-jms_1.1_spec
106 | Active |  80 | 2.0.13         | Apache MINA Core
174 | Active |  80 | 20160212.0.0   | JSON in Java
193 | Active |  80 | 1.0.0.SNAPSHOT | Chapter 5 :: Recipe 2 ::

Please let me know if we can create Jira connection with apache cxf jars.

ServerAlias in apache, ubuntu

I have a virtual host in ubuntu on apache, this is not my main config, i have another web page as my main, so i wanted to set this one up on the same IP using a virtual host.

urologyexpert.mx is my server name, and this works perfect, but i want to have several aliases to access this page

I put as server alias:
www.urologyexpert.mx (doesn't work)
urologoexpertomonterrey.mx (doesn't work)
www.urologoexpertomonterrey.mx (working)

The one's that does not work gets routed to my default webpage on this IP,

here's my apache config in /etc/apache2/sites-enabled

A records are set up for urologyexpert.mx and urologoexpertomonterrey.mx, both pointing at the same IP, and i have a CNAME for www for urologyexpert.mx

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName urologyexpert.mx
    ServerAlias www.urologyexpert.mx, urologoexpertomonterrey.mx, www.urologoexpertomonterrey.mx

    DocumentRoot /var/www/urologyexpert.mx
    <Directory />
            Options FollowSymLinks
            AllowOverride All
    </Directory>
    <Directory /var/www/urologyexpert.mx>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride All
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Can someone help me with this? i just can't figure out why one alias is working and two aren't

How do I serve index.html with .htaccess

I have an angular app at someip.com/mysite/

In my .htaccess, I have

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_URI} !/api

RewriteRule ^.*$ - [NC,L]
RewriteRule ^$ /mysite/index.html [NC,L]

Within my angular code, it redirects to someip.com/mysite/reservations/new and Apache tries to look for that instead of just serving index.html

What am I doing wrong?

There's one additional condition.. someip.com/mysite/admin should serve the admin.html page instead of index.html

.htaccess is not working in wamp

Below is my .htaccess file which is not working locally(wamp)..

    Options +FollowSymLinks -MultiViews
    RewriteEngine On

    RewriteRule ^[a-zA-Z0-9]{40}$ search.php?hash=$1

    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index($|\ |\?)
    RewriteRule ^ /%1 [R=301,L]

    RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
    RewriteRule ^ %1 [R,L,NC]

    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^ %{REQUEST_URI}.php [L]

    ErrorDocument 404 /pivr/error.php

    <Files .htaccess>
    order allow,deny
    deny from all
    </Files> 

Apache Error log says..

[Wed Aug 17 21:00:33.766183 2016] [core:alert] [pid 5780:tid 900] [client      ::1:50180] C:/wamp/www/search/.htaccess: Invalid command 'RewriteEngine',     perhaps misspelled or defined by a module not included in the server configuration

I keep getting 500 internal Server error how to fix it?

Apache Tomcat/7.0.35 SSL Certificate Install

I have been tasked with installing an SSL certificate on an Apache Tomcat server (version 7.0.35). This is not something I have had any experience with before so hoping for a little guidance! The notes I have found online seem only to cover new installations.

Looking at the server.xml file I can see that there are existing SSL certificates on there as well as keystore configurations.

Please could any one advise me what the process is for generating and adding a new SSL certificate when there are already some present in server.xml? For example do I need to remove the existing instances or can I just add a new one, are further changes needed to the keystore file?

Running a php file outside of WordPress directory

I've setup my Wordpress install in a directory called public. I have an .htaccess file in the root that uses the Wordpress directory as the default to keep any files I have in the root from being exposed to the visitor.

Now I want to run a php file in the root without the Wordpress directory "effecting" it. By that I mean not applying the theme styling from the Wordpress site. How is this accomplished?