• I am in the process of rebuilding a website. I’ve had to reverse engineer a lot of it and am now about to replace the old site. I had a look at the .htaccess file on the server and it has code in it that I don’t understand. I would like some help understanding what each line does if anyone is familiar with the code used in .htaccess files.

    Here is the code:

    Options +FollowSymlinks
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    
    RewriteRule ^(.+\.!)/$ $1 [R=301,L]
    RewriteRule ^([A-Za-z0-9-]+)(/?)$ /index.php?p=$1 [L]
    RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)(/?)$ /index.php?p=$1&v=$2 [L]
    
    </IfModule>

    Any help would be appreciated.
    Thanks.

Viewing 1 replies (of 1 total)
  • Thread Starter Dave333

    (@dave333)

    Actually, I was looking at the wrong file. Here is the code that needs deciphering:

    ErrorDocument 404 https://website.com/404
    
    Options +FollowSymlinks
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    
    ## REMOVE TRAILING SLASH
    RewriteRule ^(.*)/$ $1 [R=301,L]
    
    ## REDIRECT REQUESTS FOR WELCOME PAGE TO SITE ROOT (avoids pagerank duplication)
    RewriteRule ^welcome$ / [R=301] [L]
    RewriteRule ^administration$ /administration/index.php  [L]
    RewriteRule ^alabama$ /index.php?page=contact&regionID=1 [L]
    RewriteRule ^contact/alabama$ /index.php?page=contact&regionID=1 [L]
    RewriteRule ^washington$ /index.php?page=contact&regionID=1 [L]
    RewriteRule ^contact/washington$ /index.php?page=contact&regionID=1 [L]
    
    ## PASS FIRST URI SEGMENT TO $p VARIABLE
    RewriteRule ^([A-Za-z0-9-]+)(/?)$ /index.php?page=$1 [L]
    
    ## PASS FIRST URI SEGMENT TO $p VARIABLE and SECOND URI SEGMENT TO $v VARIABLE
    RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)(/?)$ /index.php?page=$1&$2=$3	 [L]
    RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)(/?)$ /index.php?page=$1&$2=$3&$4=$5	 [L]
    
    </IfModule>

    The commenting helps understand the intended function of the code but is there a glossary or something that someone can refer me to that explains all the details, such as what ^, (/?), [L], etc. mean?

    (There are more states than just Alabama and Washington but I wanted to keep it simple so stripped the rest out).

    Thanks

Viewing 1 replies (of 1 total)
  • The topic ‘.htaccess decipher request’ is closed to new replies.