Note that there are some explanatory texts on larger screens.

plurals
  1. POConverting mod_rewrite rules in .htaccess to httpd.conf
    text
    copied!<p>I have a set of html files at: www.example.com and the "main site" (in beta) at: www.example.com/abcd/ (for which these mod_rewrite rules are needed)</p> <p>The mod_rewrite rules run fine in a directory within .htaccess. I need to put them in httpd.conf:</p> <p>The rules look like this in .htaccess:</p> <pre><code>RewriteEngine On RewriteBase /abcd/ RewriteRule ^.*/codelibrary/(.*)$ codelibrary/$1 [L] RewriteRule ^.*/in_upload/images/(.*)$ in_upload/images/$1 [L] ... </code></pre> <p>Copying the below into the httpd.conf file didnt work:</p> <pre><code>&lt;VirtualHost *:80&gt; ServerAlias www.example.com ServerAdmin nobody@example.com DocumentRoot /var/www/html ServerSignature On &lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteBase /abcd/ ... </code></pre> <p>It gave an error:</p> <pre><code>RewriteBase: only valid in per-directory config files </code></pre> <p>Do I need to modify all rules like this?</p> <pre><code>RewriteRule ^.*/abcd/codelibrary/(.*)$ abcd/codelibrary/$1 [L] RewriteRule ^.*/abcd/in_upload/images/(.*)$ abcd/in_upload/images/$1 [L] </code></pre> <hr> <p><strong>Edit1</strong></p> <p>I tried to convert the following lines from:</p> <pre><code>... RewriteRule (.*)ins.html$ browse.php?type=ins [L] ... RewriteRule ^([a-zA-Z\-]*)/([a-zA-Z0-9\s]*)/([0-9]*)\.html$ browse.php?type=$1&amp;catId=$3 [L] RewriteRule ^([a-zA-Z\-]*)/([a-zA-Z0-9\s]*)/([a-zA-Z0-9\s]*)/([0-9]*)/([0-9]*)\.html$ browse.php?type=$1&amp;catId=$4&amp;subCatId=$5 [L] ... </code></pre> <p>To:</p> <pre><code>... RewriteRule ^/abcd/ins.html$ abcd/browse.php?type=ins [L] ... RewriteRule ^/abcd/([a-zA-Z\-]*)/([a-zA-Z0-9\-\s]*)/([0-9]*)\.html$ abcd/browse.php?type=$1&amp;catId=$3 [L] RewriteRule ^/abcd/([a-zA-Z\-]*)/([a-zA-Z0-9\-\s]*)/([a-zA-Z0-9\-\s]*)/([0-9]*)/([0-9]*)\.html$ abcd/browse.php?type=$1&amp;catId=$4&amp;subCatId=$5 [L] ... </code></pre> <p>but I got errors as follows.</p> <p>When I try accessing <a href="http://www.example.com/abcd/ins/Sustainability/282.html" rel="nofollow noreferrer">http://www.example.com/abcd/ins/Sustainability/282.html</a> , I get the following error in the log:</p> <pre><code>IPADDRESS - - [DATETIME] [www.example.com/sid#2b3cde3c1be0][rid#2b3cec076e70/initial] (2) init rewrite engine with requested uri /abcd/ins/Sustainability/282.html IPADDRESS - - [DATETIME] [www.example.com/sid#2b3cde3c1be0][rid#2b3cec076e70/initial] (2) rewrite '/abcd/ins/Sustainability/282.html' -&gt; 'abcd/browse.php?type=ins&amp;catId=282' IPADDRESS - - [DATETIME] [www.example.com/sid#2b3cde3c1be0][rid#2b3cec076e70/initial] (2) local path result: abcd/browse.php </code></pre> <p>When I try accessing <a href="http://www.example.com/abcd/ins.html" rel="nofollow noreferrer">http://www.example.com/abcd/ins.html</a> , I get the following error in the log:</p> <pre><code>IPADDRESS - - [DATETIME] [www.example.com/sid#2b3cde3c1be0][rid#2b3cec076e70/initial] (2) init rewrite engine with requested uri /abcd/ins.html IPADDRESS - - [DATETIME] [www.example.com/sid#2b3cde3c1be0][rid#2b3cec076e70/initial] (2) rewrite '/abcd/ins.html' -&gt; 'abcd/browse.php?type=ins' IPADDRESS - - [DATETIME] [www.example.com/sid#2b3cde3c1be0][rid#2b3cec076e70/initial] (2) local path result: abcd/browse.php </code></pre> <p>I've set RewriteLogLevel to 2</p> <p>The unmodified version of our mod_rewrite rules are at: <a href="https://webmasters.stackexchange.com/questions/4237/url-rewritten-pages-take-much-longer-to-load">https://webmasters.stackexchange.com/questions/4237/url-rewritten-pages-take-much-longer-to-load</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload