Note that there are some explanatory texts on larger screens.

plurals
  1. POmodrewrite RewriteRule problem
    text
    copied!<p>I am using Apache 2.2 and mod_rewrite. I would like to take the following urls and map them to another url. The pattern is simple and like this:</p> <p><a href="http://domain/test/ex1.html" rel="nofollow noreferrer">http://domain/test/ex1.html</a> -> <a href="http://domain/app/index.php/content/?name=ex1" rel="nofollow noreferrer">http://domain/app/index.php/content/?name=ex1</a></p> <p>I tried the following in an .htaccess file (place in /test/ directory in docroot):</p> <pre><code>RewriteEngine On RewriteBase /app/ RewriteRule (.*)\.html index.php/content/?name=$1 </code></pre> <p>and </p> <pre><code>RewriteEngine On RewriteRule (.*)\.html /app/index.php/content/?name=$1 </code></pre> <p>I wasn't sure if the backreference was correct so set to $0 and $2 but never seemed to help.</p> <p>I also tried setting the RewriteLogLevel to 9. </p> <p>There is a step where it is almost there: rewrite 'ex1.html' -> 'index.php/content/?name=ex1'</p> <p>The last line of the rewrite log is as follows: [perdir /var/www/domain/htdocs/test/] internal redirect with /app/index.php/content/ [INTERNAL REDIRECT]</p> <p>How can I get this to rewrite to /app/index.php/content/?name=ex1 ?</p> <p>EDIT so using this as an .htacces in the docroot file works for the RedirectMatch:</p> <pre><code>RewriteEngine On RewriteBase / RedirectMatch ^(.*)/(.*)\.html$ http://domain/app/index.php/content/?name=$2 #this doesnt work - adding to docroot allows for it to pick up but still using test/ex1 rather than just ex1 #RewriteRule ^(.*)\.html$ /app/index.php/content/?name=$1 </code></pre> <p>Any help getting the bottom RewriteRule (that is currently commented out) to work would be appreciated. </p> <p>thanks</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