Forum Moderators: phranque

Message Too Old, No Replies

Modifying Directory Paths within .htaccess

htaccess modify

         

el_roboto

1:39 pm on Mar 13, 2007 (gmt 0)

10+ Year Member



Hello...Help

never touched .htaccess and now I'm required to modify it for an installation.

The syntax looks completely alien to me, particularly when it comes to stating paths, so I'm hoping someone can help me out as I'm worried I'd ruin the file

heres the existing file
-----------------------


Options FollowSymLinks
# RewriteOptions MaxRedirects=50
RewriteEngine On
RewriteBase /
RewriteRule ^index(/)?$ index.php
RewriteRule ^department/([^/]*)/([^/]*)/([^/]*)(/)?$ ecom/index.php?action=ecom.details&mode=$1&$2=$3 [nc]
RewriteRule ^department/([^/]*)(/)?$ ecom/index.php?action=ecom.details&mode=$1 [nc]
RewriteRule ^product/([^/]*)/([^/]*)/([^/]*)(/)?$ ecom/index.php?action=ecom.pdetails&mode=$1&$2=$3 [nc]
RewriteRule ^product/([^/]*)(/)?$ ecom/index.php?action=ecom.pdetails&mode=$1 [nc]
RewriteRule ^content/([^/]*)(/)?$ ecom/index.php?action=ecom.cdetails&mode=$1 [nc]
RewriteRule ([^/]*)/action/([^/]*)/([^/]*)/([^/]*)/([^/]*)(/)?$ $1/index.php?action=$2&mode=$3&$4=$5 [nc]
RewriteRule ([^/]*)/action/([^/]*)/([^/]*)(/)?$ $1/index.php?action=$2&mode=$3 [nc]
RewriteRule ([^/]*)/action/([^/]*)(/)?$ $1/index.php?action=$2 [nc]
RewriteRule ^eaction/([^/]*)/([^/]*)/([^/]*)/([^/]*)(/)?$ ecom/index.php?action=$1&mode=$2&$3=$4 [nc]
RewriteRule ^eaction/([^/]*)/([^/]*)(/)?$ ecom/index.php?action=$1&mode=$2 [nc]
RewriteRule ^action/([^/]*)/([^/]*)(/)?$ index.php?action=$1&mode=$2 [nc]
RewriteRule ^sid/([^/]*)(/)?$ index.php?sid=$1 [nc]
## Error Handling ##
#RewriteRule ^error/([^/]*)(/)?$ index.php?action=error&mode=$1 [nc]
# ----------------------------------- Content Section ------------------------------ #
#RewriteRule ^([^/]*)(/)?$ index.php?action=cms&mode=$1 [nc]
RewriteRule ^accessibility(/)?$ index.php?action=cms&mode=accessibility
RewriteRule ^terms(/)?$ index.php?action=cms&mode=conditions
RewriteRule ^privacy(/)?$ index.php?action=cms&mode=privacy
RewriteRule ^memberpoints(/)?$ index.php?action=cms&mode=member_points
RewriteRule ^contactus(/)?$ index.php?action=contactus
RewriteRule ^sitemap(/)?$ index.php?action=sitemap
ErrorDocument 404 /index.php?action=error&mode=content

-----------------------

because this isn't going into the root, I need to modify the file to work when its in /~cnwywcum/

jdMorgan

2:47 pm on Mar 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That's some pretty poor code, as it uses ambiguous patterns and is missing the generally-recommended [L] flag on most rules, among other things. If you have no working knowledge of mod_rewrite, I strongly recommend that you read the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com] before starting. As you suspect, modifying code you don't understand can be quite dangerous to the health of your server and your Web site(s)...

It appears from your statement about "making this work in /~cnwywcum/" that you are using mod_userdir [httpd.apache.org], where users have "accounts" and access their pages with URLs like "example.com/~cnwywcum/page.html" and those URLs are mapped into the server filesystem as, for example, example.com/users/cnwywcum/page.html. If this is the case, you will need to determine the exact nature of the current mod_userdir "mapping" before proceeding -- This information should be available in the server config file.

My recommendation would be to find the person that coded this file originally, and work with him/her on this project for best chances of success. Since we here can't sit next to you and look over your shoulder to observe your test results, trying to accomplish this task in a forum venue is going to take an awful lot of time.

Jim