Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <a href="http://httpd.apache.org/docs/2.2/mod/mod_alias.html#redirect" rel="nofollow noreferrer"><code>Redirect</code></a> directive does only work with the <a href="http://httpd.apache.org/docs/2.2/mod/directive-dict.html#Syntax" rel="nofollow noreferrer">URL path</a> but not the host or query of the URL.</p> <p>But it is possible with <a href="http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html" rel="nofollow noreferrer">mod_rewrite</a>:</p> <pre><code>RewriteCond %{HTTP_HOST} =example.org RewriteCond %{QUERY_STRING} =id=1 RewriteRule ^default\.asp$ http://www.example.org/newpage.html [NC,L,R=301] </code></pre> <p>And as already said in the comments, you can use a <a href="http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritemap" rel="nofollow noreferrer">rewrite map</a> for the ID-to-alias mapping:</p> <pre><code>1 foo-page 2 bar-page 3 baz-page … </code></pre> <p>The <code>RewriteMap</code> declaration (here a simple plain text file):</p> <pre><code>RewriteMap id-to-alias txt:/absolute/file/system/path/to/id-to-alias.txt </code></pre> <p>And finally the application:</p> <pre><code>RewriteCond %{HTTP_HOST} =example.org RewriteCond %{QUERY_STRING} ^(([^&amp;]*&amp;)*)id=([0-9]+)&amp;?([^&amp;].*)?$ RewriteCond ${id-to-alias:%3}&amp;%1%4 ^([^&amp;]+)&amp;(.*) RewriteRule ^default\.asp$ http://www.example.org/%1.html?%2 [NC,L,R=301] </code></pre> <p>That should also preserver the remaining query. If you don’t want that:</p> <pre><code>RewriteCond %{HTTP_HOST} =example.org RewriteCond %{QUERY_STRING} ^(([^&amp;]*&amp;)*)id=([0-9]+)&amp;?([^&amp;].*)?$ RewriteCond ${id-to-alias:%3} .+ RewriteRule ^default\.asp$ http://www.example.org/%0.html? [NC,L,R=301] </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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