LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-19-2018, 07:02 PM   #1
acascianelli
Member
 
Registered: Oct 2002
Location: Michigan
Posts: 71

Rep: Reputation: 15
Apache/ModRewrite Help


Running Ubuntu 18.04.

I'm trying to setup a web client for KeePass called KeeWeb:

https://github.com/keeweb/keeweb

There is an option to reference a JSON config file from the URL to specify some options, but I cannot figure out what mod_rewrite rule I need in order to append the query string to the end of the page index. See link for details.

https://github.com/keeweb/keeweb/wiki/Configuration

I know I could just modify the index.html to include the path to the config file, but I don't want to run it that way.

Basically I need to convert https://www.example.com/KeeWeb/index.html to https://www.example.com/KeeWeb/index...ig=config.json
 
Old 07-19-2018, 09:51 PM   #2
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.5
Posts: 1,418

Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
Assuming apache: See the documentation here
mod_rewrite: https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html

See #4 link in my signature.

check back if you have problems.
 
Old 07-20-2018, 10:13 AM   #3
acascianelli
Member
 
Registered: Oct 2002
Location: Michigan
Posts: 71

Original Poster
Rep: Reputation: 15
I've been tinkering with different combinations of rewrite rules for days with no luck.

I think my problem is the mod_dir module that Ubuntu is using with Apache out of the box. It is preventing me from matching index.html with any re-write rule.
 
Old 07-20-2018, 10:24 AM   #4
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.5
Posts: 1,418

Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
Please post the rule you're trying...in [code] tags (see link #3 in my signature)

We can't help much when you say things like "What I'm trying doesn't work"...we need to see what you're trying..and we need to see what happens when it "doesn't work"

Out-of-the-box apache should be able to handle a rewrite rule.

PS: I'm not sure why you want to futz with your apache configuration when adding a meta-tag to your index.html will do the job, according to the KeeWeb documentation you posted...

Last edited by scasey; 07-20-2018 at 10:28 AM.
 
Old 07-20-2018, 02:18 PM   #5
acascianelli
Member
 
Registered: Oct 2002
Location: Michigan
Posts: 71

Original Poster
Rep: Reputation: 15
Here is the last rule I left off with. The page would be under something like www.example.com/asdf/index.html.

Code:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^/?index.html$ %{REQUEST_URI}?config=config.json [QSA,R,L]
Checking to see if the query string is empty, and if it is append one onto the end.

Last edited by acascianelli; 07-20-2018 at 02:38 PM.
 
Old 07-20-2018, 02:47 PM   #6
acascianelli
Member
 
Registered: Oct 2002
Location: Michigan
Posts: 71

Original Poster
Rep: Reputation: 15
Son of a bitch. I made a typo and I think I got it to work...

Code:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^ %{REQUEST_URI}?config=config.json [QSA,R,L]
 
Old 07-20-2018, 02:51 PM   #7
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.5
Posts: 1,418

Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
That rule is looking for a literal /? at the beginning of the URI...something like
Code:
http:///?index.html
so no domain name, etc.

...you do have the "ends with index.html" part right

Is this the only index.html on your server? (I'm thinking probably not)

Why not just match the whole URI you want to change:
Code:
RewriteRule ^*.example.com/asdf/index.html$ %{REQUEST_URI}?config=config.json
?? (Obviously, I can't test that...) * at the beginning is to match with or without www

But, I still am of the opinion that a meta tag in that index.html is the better solution. Just sayin'. It's specific to the one page; you don't risk rewriting some other page by accident, and it's one of the two preferred ways in the documentation. Have you tried that?
 
Old 07-20-2018, 03:21 PM   #8
acascianelli
Member
 
Registered: Oct 2002
Location: Michigan
Posts: 71

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by scasey View Post
But, I still am of the opinion that a meta tag in that index.html is the better solution. Just sayin'. It's specific to the one page; you don't risk rewriting some other page by accident, and it's one of the two preferred ways in the documentation. Have you tried that?
I have tried the meta tag, and that works fine too. I'm just tinkering around with both options and wanted to get it working.

Thank you for your help.
 
Old 07-20-2018, 04:31 PM   #9
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.5
Posts: 1,418

Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
Quote:
Originally Posted by acascianelli View Post
Son of a bitch. I made a typo and I think I got it to work...

Code:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^ %{REQUEST_URI}?config=config.json [QSA,R,L]
OK...doesn't that add ?config=config.json to every request? Even ones that already have the query string?

Still, I'm glad you got it working.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Apache httpd 2.4 ModRewrite rules ddench Linux - Server 4 04-25-2015 12:36 PM
Apache close wait error :Apache stop responding,Server get hangs jsaravana87 Linux - Server 1 06-19-2012 11:49 AM
modrewrite enabled but not working?? simonm Linux - Newbie 1 10-12-2008 12:59 PM
Apache :: ModRewrite ? c0nsur Linux - Software 5 03-31-2006 09:38 PM
apache benchmarks (apache v13 / apache v20) ; large differences between benchmarking markus1982 Linux - Software 0 02-08-2003 10:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration