Dynamic URL rewrite with .htaccess -


migrating site iis apache , i'm having trouble rewriterule can't find answer to.

i need redirect www.domain.com/pubs/books/p123.asp www.domain.com/books.php?p=p123.

no matter try, i'm getting 404.

can give me pointer? examples seem find have dynamic part of url @ end. first need strip .asp?

drupal running on site there rewriterules there to.

the latest have tried is: rewriterule /pubs/books/p(.*)$.asp /books.php?p=$1

first of all: read documentation! can find here.

it says:

syntax: rewriterule pattern substitution [flags]

and

in virtualhost context, pattern matched against part of url after hostname , port, , before query string (e.g. "/app1/index.html").

in directory , htaccess context, pattern matched against filesystem path, after removing prefix led server current rewriterule (e.g. "app1/index.html" or "index.html" depending on directives defined).

if wish match against hostname, port, or query string, use rewritecond %{http_host}, %{server_port}, or %{query_string} variables respectively.

(in other words: pattern starting slash never match if in .htaccess context)


first of all, make sure mod_rewrite enabled , rewriteengine on (put rewriteengine on in .htaccess) , allowed there (see docs).

assuming in .htaccess in www-root, should work:

rewriterule ^pubs/books/p(.*)\.asp$ books.php?p=$1 [l] 

the syntax ^...$ makes sure entire filesystem path. wouldn't want match http://example.com/some/more/paths/pubs/books/p123.asp here , rewrite that.


Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -