How to remove query string variable from url

How to remove query string variable name from htaccess ? I have following structure.

http://localhost/newsite/category?id=News
http://localhost/newsite/category?id=Entertainment
http://localhost/newsite/category?id=Technology

I want to change

http://localhost/newsite/News/
http://localhost/newsite/Entertainment/
http://localhost/newsite/Technology/

like this. I tried rewriting in htaccess, but doesn't work

Protocol concerning connections with Apache Derby with Java

I am building an application that needs to regularly access an internal Apache Derby database.

I am wondering if I should be closing the applications connection after every set of statements is complete or if I can leave the connection open.

The application will only be used and accessed by one user at any given time.

Would your answer change if I was using an external database?

Thanks.

Ubuntu 18.04 apache and Certbot

Attempting to install Certbot for LetsEncrpyt on Ubuntu 18.04 running apache and receive the following:

sudo add-apt-repository ppa:certbot/certbot Cannot add PPA: 'ppa:~certbot/ubuntu/certbot' The team named '~certbot' has no PPA named 'ubuntu/cerbot' Please choose from the following available PPAs: * 'cerbot': Certbot PPA * 'certbot-build':

A bit new to Ubuntu but am I missing something here. The PPA is there but it's not available?

Ubuntu 18.04 apache and Certbot

Attempting to install Certbot for LetsEncrpyt on Ubuntu 18.04 running apache and receive the following:

sudo add-apt-repository ppa:certbot/certbot Cannot add PPA: 'ppa:~certbot/ubuntu/certbot' The team named '~certbot' has no PPA named 'ubuntu/cerbot' Please choose from the following available PPAs: * 'cerbot': Certbot PPA * 'certbot-build':

A bit new to Ubuntu but am I missing something here. The PPA is there but it's not available?

Login-only root (no links) with a directory hidden (via apache2.conf) to keep crawlers or bots from the hidden dirs?

The hidden content is not super-sensitive but I don't want it indexed anywhere or easily found.

I'm trying to avoid .htaccess after reading somewhere? that it complicates API use.

I'm hesitant to use robots.txt considering these concerns.

In other words, if "example.com/index.html" does not expose links to the rest of the directory (and no other external links lead to them either) are "hidden" parts of the directory unable to be indexed?

Oscommerce to OpenCart Redirects

The way that Oscommerce SEO Friendly URLs work, is that they are generated from a product or category title followed by a p for product and c for category, then the product or category ID. For categories, each parent directory ID is also used. for example:

https://example.com/jeep-pinion-gears-c-284_845.html

over the course of many years, products and categories get edited and moved therefore changing the URL. However, all the old URL's still resolved because pages are served strictly based off of the last part of the URL. It looks for the c or p and the ID's. SEO is still able to be maintained. For Example:

https://example.com/jeep-pinion-gears-c-284_845.html
https://example.com/jeep-pinion-gears-and-accessories-c-284_845.html
https://example.com/jeep-pinion-gears-c-284_1234_845.html
https://example.com/ring-pinion-gears-c-845.html

Would all load the same content.

I've recently changed over to OpenCart where I used the latest URL for each product and category from the OsCommerce store. However, all the of Old Oscommerce URL's don't work.

I was originally writing some regex redirects to match the ID's but I'm running into redirect loop issues.

Does anyone any any ideas on a different approach?

htaccess redirect all domain except one subfolder including the files and other subfolders inside

I'm currently using:

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/folder/.*
RewriteCond %{REQUEST_URI} !^/folder$
RewriteRule .* https://www.newdomain.com/ [R=301,L]

Which works great at redirecting the "folder" to the "newdomain," including the files within that folder, however, the subfolders within that folder still redirect.

I've tried:

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/folder/.*
RewriteCond %{REQUEST_URI} !^/folder$
RewriteCond %{REQUEST_URI} !^/folder/subfolder/.*
RewriteCond %{REQUEST_URI} !^/folder/subfolder$
RewriteRule .* https://www.newdomain.com/ [R=301,L]

As well as:

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/folder/.*
RewriteCond %{REQUEST_URI} !^/folder$
RewriteCond %{REQUEST_URI} !^/subfolder/.*
RewriteCond %{REQUEST_URI} !^/subfolder$
RewriteRule .* https://www.newdomain.com/ [R=301,L]

with no luck.

Any suggestions?

Apache Cordova $.ajax not working( using Web.APİ)

im making an mobile app using API but ajax not working. i take breakpoint on ajax but not see. and my other project is work and they are exactly the same .and the jquery codes in this project are working

This inside onDeviceReady

$.ajax({

            method: "post",
            url: "http://localhost:53407/api/kullanici/kullanicikayit",
            data: yeniKullanici,
            success: function () {
                alert("Kayıt Başarılı");
                window.location.href = "index.html";
            },
            error: function () {
                alert("Lütfen bilgilerinizi kontrol ederek tekrar deneyiniz.");
            },
        });

and this is my APİ Controller

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.Cors;
using BitirmeProjesi.Server.Models;

namespace BitirmeProjesi.Server
{
    [EnableCors("*","*","*")]
    public class KullaniciController : ApiController
    {
        [HttpPost]
        public void KullaniciKayit(Kullanicilar kullanici)
        {
            Kullanicilar yeniKullanici = new Kullanicilar();
            
            yeniKullanici.KullaniciAdi = kullanici.KullaniciAdi;
            yeniKullanici.Mail = kullanici.Mail;
            yeniKullanici.RoleId = 1;
            yeniKullanici.Sifre = kullanici.Sifre;
            yeniKullanici.Soyad = kullanici.Soyad;
            yeniKullanici.Ad = kullanici.Ad;
            db.Kullanicilar.Add(yeniKullanici);
            db.SaveChanges();
        }

    }
}

`

The utlimate way to make a single entry point (front controller) working with the most common web server setups

That's not gonna be easy, thanks to all reading this! :)

;TL;DR;

How can we know what is the 'DOCUMENT_ROOT' regardless the webserver (nginx/apache/apache with hattacces) setup.

Introduction

I'll try to be as descriptive as possible :)

It's all about forwarding all the requests to a single index.php file (excluding existing files). Yes, a pretty common tasks.

Project lives in: /var/www/html/point/point1

This might be both dev or prod env.

I want all the requests to go to "index.php" with the information about what actually was requested.

Details

Assuming the the project's host is 'point1" and it lives in /var/www/html/point/point1 -

When user enters http://point1/foo/bar - I want the webserver to run /var/www/html/point/index.php and send the info about requested URL to it (in this case /foo/bar).

I want to know the 'foo' and 'bar';

It's quite with vhosts on both apache and nginx Like in apache :

<directory /var/www/html/point/point1>
      RewriteEngine On
      RewriteCond %{SCRIPT_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^.*$ index.php
</directory>  

And nginx:

location /{
    server_name point1;
    root /var/www/html/point/point1;
    try_files $uri $uri/ /index.php$is_args$args
}
location ~ \.php$ {
 #...handle php
}

It's easy because what we can easily get the "remaining part" in the

 var_dump($_SERVER['REQUEST_URI']); 

The "REQUEST_URI" var tells us what is after the 'host'.

Fine.

Now the .htaccess comes in. Assuming the user has no access to the webserver settings, here is the typical way:

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,L]

Or just RewriteRule ^(.*)$ index.php Yeah, I know there is a difference.

Problem

I want my script to handle all these situations. It's easy if we limited it to 'vhosts'. In this case the 'document root' is known. This why this works:

$request = $_SERVER['REQUEST_URI']);
$file =  $_SERVER['REQUEST_URI'][1];
$method =  $_SERVER['REQUEST_URI'][2];

We know that $file is now relative to $_SERVER['DOCUMENT_ROOT'];

Except that when I want to support .htaccess it isn't that easy. Because I don't know the "document_root".

What I get in "$_SERVER['REQUEST_URI']" is "/point/point1/foo/bar" and I don't really know what is the part responsible for "foo" and "bar";

It seems that in Symfony this part of code deals with it:

https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/Request.php#L1826

But I'm not really sure.

What I have done so far is that I put into .htaccess this:

Hi.

Introduction

I'll try to be as descriptive as possible :)

It's all about forwarding all the requests to a single index.php file (excluding existing files). Yes, a pretty common tasks.

Project lives in: /var/www/html/point/point1

This might be both dev or prod env.

I want all the requests to go to "index.php" with the information about what actually was requested.

Details

Assuming the the project's host is 'point1" and it lives in /var/www/html/point/point1 -

When user enters http://point1/foo/bar - I want the webserver to run /var/www/html/point/index.php and send the info about requested URL to it (in this case /foo/bar).

I want to know the 'foo' and 'bar';

It's quite with vhosts on both apache and nginx Like in apache :

<directory /var/www/html/point/point1>
      RewriteEngine On
      RewriteCond %{SCRIPT_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^.*$ index.php
</directory>  

And nginx:

location /{
    server_name point1;
    root /var/www/html/point/point1;
    try_files $uri $uri/ /index.php$is_args$args
}
location ~ \.php$ {
 #...handle php
}

It's easy because what we can easily get the "remaining part" in the

 var_dump($_SERVER['REQUEST_URI']); 

The "REQUEST_URI" var tells us what is after the 'host'.

Fine.

Now the .htaccess comes in. Assuming the user has no access to the webserver settings, here is the typical way:

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,L]

Or just RewriteRule ^(.*)$ index.php Yeah, I know there is a difference.

Problem

I want my script to handle all these situations. It's easy if we limited it to 'vhosts'. In this case the 'document root' is known. This why this works:

$request = $_SERVER['REQUEST_URI']);
$file =  $_SERVER['REQUEST_URI'][1];
$method =  $_SERVER['REQUEST_URI'][2];

We know that $file is now relative to $_SERVER['DOCUMENT_ROOT'];

Except that when I want to support .htaccess it isn't that easy. Because I don't know the "document_root".

What I get in "$_SERVER['REQUEST_URI']" is "/point/point1/foo/bar" and I don't really know what is the part responsible for "foo" and "bar";

It seems that in Symfony this part of code deals with it:

https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/Request.php#L1826

But I'm not really sure.

What I have done so far is this, in .htaccess:

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
SetEnv USE_URI_PROTOCOL PATH_INFO

As you can see I am setting an environment var so I can use it later in my php single entry point:

$uriProtocol = getenv('USE_URI_PROTOCOL')?:'REQUEST_URI';
    $request = isset($_SERVER[$uriProtocol])?$_SERVER[$uriProtocol]:'';

    //getting only what's before ? (uri query string) if it exists 
    if (($pos = strpos($request, '?')) !== false){
        $request = substr($request, 0, $pos);
    } 

    //trimming slashes
    $request = trim($request, '/');
    $requestArray  = empty($request)? [] : explode('/', $request);

    var_dump('controller',$requestArray[0] ?? 'undefined');
    var_dump('method',$requestArray[1] ?? 'undefined');

It works. But something tells me it's not very cool.

I hope I'm clear here? It's about one-single-easy-solution-to-do-the-front-controller.

Just another Blog Hosting Sites site