Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite / .htaccess convert Apache 1.3.42 to Apache 2.4.12

         

ingenuitor

10:28 pm on May 12, 2015 (gmt 0)

10+ Year Member



Hello Guys, been a long time since I have used this site and in fact this maybe my first post. can anyone help me with a mod_rewrite issue?

The file structure is as follows

Public files: /home/usrname/public_html
CGI BIN, where the software is running: /home/usrname/public_html/cgi-bin
Private files: /home/usrname/public_html/_private
Databases: /home/usrname/public_html/_private/data

What I would like to do is convert this to an Apache 2.4.12 .htaccess file, seemly a few changes during the SSL path are what I get hung on mainly. When you try any documents with the SSL path all I see if the _private path and not the public_html path in the html source for any file types, like, css, js images and anything else.

We also have a permissions issues, which is asking for us to login during checkout, this must be due to of of the other .htaccess settings. It should be simple, yet somehow I'm not getting the rules correctly in-line just yet.

Here are the lines of code in each .htaccess file

Public files: /home/usrname/public_html

RewriteEngine On

RewriteCond %{HTTP_HOST} ^99\.00\.99\.000$
RewriteRule ^/?(.*)$ http://www.mydomain.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^mydomain.com$
RewriteRule ^/?(.*)$ http://www.mydomain.com/$1 [R=301,L]

RewriteCond /home/usrname/public_html/%{REQUEST_FILENAME} -f
RewriteRule ^(.+) /home/usrname/public_html/$1 [L]
RewriteCond /home/usrname/public_html/_private/%{REQUEST_FILENAME} -f
RewriteRule ^(.+) /home/usrname/public_html/_private/$1 [L]
RewriteRule ^(.+) - [PT]

DirectoryIndex home.html index.htm index.html default.htm Default.htm
Action cgi-ccd /cgi-bin/ccd.cco
AddHandler cgi-ccd html
AddHandler default-handler .gif
AddHandler default-handler .jpg

<FilesMatch "\.(inx|weo|lco|dbo|cdo|fpo|dao)">
Order Allow,Deny
Allow from env=local_ref
</FilesMatch>

<Files 403.shtml>
order allow,deny
allow from all
</Files>


We also have these .htaccess files on the account in their respective paths.

Private files: /home/usrname/public_html/_private

AuthUserFile .htpasswd
AuthGroupFile /dev/null
AuthName Administrator
AuthType Basic
<limit GET>
require valid-user
</limit>


Databases: /home/usrname/public_html/_private/data

AuthUserFile .htpasswd
AuthGroupFile /dev/null
AuthName Administrator
AuthType Basic
<limit GET>
require valid-user
</limit>


CGI BIN: /home/usrname/public_html/cgi-bin

Options +ExecCGI
Order allow,deny
Allow from all


Perhaps there is something with the way these all work together that are the issue now in Apache 2.4+ ? Perhaps it's the permissions with calling the file from the CGI-BIN directory, I can move this if needed? The 301 redirects are fairly simple, seemly. The syntax may need changed, but they seem simple enough to program. We think there is some conflict with something like Options FollowSymLinks SymLinksIfOwnerMatch ExecCGI Includes MultiViews or some other combination; I have tried several combinations with no luck.

In the end all I'm trying to do mask the full path cgi-bin path of the software, yet provide the old path back as a 301 redirect so we do not lose any links that may be indexed and or bookmarked.

.i.e.

From: http://www.example.com/cgi-bin/ccd.cco/any-document-filename.html
To: http://www.example.com/anydocumentname.html

or in SSL mode.

From: https://www.example.com/cgi-bin/ccd.cco/any-document-filename.html
To: https://www.example.com/anydocumentname.html

Best regards and Thank You for any help...

[edited by: engine at 8:18 am (utc) on May 13, 2015]

[edited by: phranque at 7:14 pm (utc) on May 19, 2015]
[edit reason] please use example.com [/edit]

lucy24

5:45 pm on May 19, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Edit: I only realized after the fact that the original post was from a week ago, not yesterday. Not sure how it got overlooked all this time.


I read only this far:
RewriteRule ^/

In htaccess, as in any <Directory> section, this will always fail. (Oddly, it may even fail if there's a malformed request for example.com//blahblah where you'd expect a leftover / slash.)

Frankly I'm confused about what you're trying to do.
convert this to an Apache 2.4.12 .htaccess file

htaccess is, by definition, a directory-specific file. So what does the physical file structure have to do with, well, anything?

RewriteCond %{HTTP_HOST} ^99\.00\.99\.000$

Wouldn't this, too, always fail? Or are these just random digits for posting purposes? In any case, you're not really going to let people into your site using the naked IP, are you? If this is meant to be a domain-name-canonicalization redirect, there are at least seventy thousand posts talking about the optimal wording. This isn't it. It's also in the wrong place; it should always be the very last external redirect. (The index redirect is typically the second-to-last. Maybe third- if you've also got http vs https rules.) More seriously, how does a request for the naked IP even make it as far as htaccess? It should have been intercepted in the config file. If there's only one domain living on the server, you generally don't need htaccess at all.

Personally I wouldn't put RewriteRules anywhere but an individual domain's root directory (the one your DNS points to for "example.com"). In fact I'm not entirely certain you can use mod_rewrite further upstream.

When you try any documents with the SSL path all I see if the _private path and not the public_html path in the html source for any file types, like, css, js images and anything else.

?! What's the physical path doing in the HTML at all? You need either site-absolute URLs beginning in / or, depending on directory structure within the domain, relative links.


The auto-linking on https:/ /example.com is not your fault. It's part of an ongoing Forums software update that will be sorted in due course.