Forum Moderators: phranque

Message Too Old, No Replies

access httpd.conf and optimising htaccess

         

kkonline

10:54 am on Sep 22, 2007 (gmt 0)

10+ Year Member



How can i access the httpd.conf file on my shared hosting (or do i have to ask the hosting provider) I want to add some <location> based tags in it to prevent direct access as discussed earlier on the forum.

Secondly I am using the following as htaccess file. The redirection is getting bigger and bigger. Is that ok or is there any other solution to optimize the htaccess file

Options +FollowSymLinks All
RewriteEngine On

# -FrontId-

IndexIgnore .htaccess */.?* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName mysite.com
AuthUserFile /home/mysite/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/mysite/public_html/_vti_pvt/service.grp
RewriteCond %{HTTP_HOST} ^mysite.net$ [OR]
RewriteCond %{HTTP_HOST} ^www.mysite.net$
RewriteRule ^(.*)$ http://mysite.com [R=301,L]

RewriteCond %{HTTP_HOST} ^mysite.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.mysite.com$
RewriteRule ^/?$ http://mysite.com/bbeta [R=302,L]

RewriteRule ^/?(1)/(user)$ dir/index.php
RewriteRule ^/?(1)/(user)/$ dir/index.php

RewriteRule ^/?(1)/(user)/(submit)$ dir/submit.php
RewriteRule ^/?(1)/(user)/(submit)/$ dir/submit.php

RewriteRule ^/?(1)/([0-9]+)/([0-9]+)/([0-9]+)(/*)$ dir/ids.php?sectionid=$1&catid=$2&id=$3&val=$4&title=$5
RewriteRule ^/?(1)/([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ dir/ids.php?sectionid=$1&catid=$2&id=$3&val=$4&title=$5

RewriteRule ^/?(1)/([0-9]+)/([0-9]+)/([a-zA-Z])$ dir/display.php?sectionid=$1&catid=$2&id=$3&alphabet=$4
RewriteRule ^/?(1)/([0-9]+)/([0-9]+)/([a-zA-Z])/$ dir/display.php?sectionid=$1&catid=$2&id=$3&alphabet=$4

RewriteRule ^/?(1)/([0-9]+)/([0-9]+)$ dir/display.php?sectionid=$1&catid=$2&id=$3
RewriteRule ^/?(1)/([0-9]+)/([0-9]+)/$ dir/display.php?sectionid=$1&catid=$2&id=$3

RewriteRule ^/?(1)/([0-9]+)/([0-9]+)/(change)$ dir/ew.php
RewriteRule ^/?(1)/([0-9]+)/([0-9]+)/(change)/$ dir/ew.php

RewriteRule ^/?([0-9]+)/([0-9]+)/([0-9]+)/(share)$ f/spreadit/spreadit.php
RewriteRule ^/?([0-9]+)/([0-9]+)/([0-9]+)/(share)/$ f/spreadit/spreadit.php

RewriteRule ^/?([0-9]+)/([0-9]+)/([0-9]+)/(post_post_comment)$ f/post_post_comment/post_post_comment.php
RewriteRule ^/?([0-9]+)/([0-9]+)/([0-9]+)/(post_post_comment)/$ f/post_post_comment/post_post_comment.php

RewriteRule ^/?([0-9]+)/([0-9]+)/([0-9]+)/(print)$ f/print/printid.php
RewriteRule ^/?([0-9]+)/([0-9]+)/([0-9]+)/(print)/$ f/print/printid.php

RewriteRule ^/?(1)/([0-9]+)/([0-9]+)/(pdf)$ f/fpdf/tutorial/pdfmodi.php?sectionid=$1&catid=$2&id=$3
RewriteRule ^/?(1)/([0-9]+)/([0-9]+)/(pdf)/$ f/fpdf/tutorial/pdfmodi.php?sectionid=$1&catid=$2&id=$3

RewriteRule ^/?(2)/(user)$ images/index.html
RewriteRule ^/?(2)/(user)/$ images/index.html

RewriteRule ^/?(2)/(user)/(submit)$ images/upload.php
RewriteRule ^/?(2)/(user)/(submit)/$ images/upload.php

RewriteRule ^/?(2)/([0-9]+)/([0-9]+)/([a-zA-Z])$ images/display.php?sectionid=$1&catid=$2&id=$3&alphabet=$4
RewriteRule ^/?(2)/([0-9]+)/([0-9]+)/([a-zA-Z])/$ images/display.php?sectionid=$1&catid=$2&id=$3&alphabet=$4

RewriteRule ^/?(2)/([0-9]+)/([0-9]+)$ images/display.php?sectionid=$1&catid=$2&id=$3
RewriteRule ^/?(2)/([0-9]+)/([0-9]+)/$ Imagess/display.php?sectionid=$1&catid=$2&id=$3

RewriteRule ^/?(2)/([0-9]+)/([0-9]+)/([0-9]+)(/*)$ iamges/ids.php?sectionid=$1&catid=$2&id=$3&val=$4&title=$5
RewriteRule ^/?(2)/([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ images/ids.php?sectionid=$1&catid=$2&id=$3&val=$4&title=$5

jdMorgan

4:06 pm on Sep 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's highly unlikely that you'll get much support for modifying httpd.conf on a shared hosting account. You can always just put individual .htaccess files in each of your corresponding <directory>s if you prefer that over putting all your code in the top-level .htaccess file and matching the <location> URL-path there.

You can easily cut the size of your .htaccess file by almost half simply by making better use of regular expressions:

First four rule-sets for example:


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

RewriteCond %{HTTP_HOST} ^(www\.)?example\.com
RewriteRule ^$ http://example.com/bbeta [R=302,L]

RewriteRule ^1/user/?$ dir/index.php [L]

RewriteRule ^1/user/submit/?$ dir/submit.php [L]

Adding the "?" quantifier, which means "zero or one of the preceding," directly after any character makes that character optional. Adding the "?" quantifier after a parenthesized group of characters makes all the parenthesized characters optional. You don't need to add parentheses anywhere unless you want to match such a quantified character group or create a back-reference.

For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim

g1smd

12:56 am on Sep 23, 2007 (gmt 0)

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



Your rewrites allow URLs both with and without a trailing / to access the content. That is a Duplicate Content issue that might harm your listings. Pick one format to index and 301 redirect the other one.