I’m trying to rewrite a specific structured url to another structure.
The original url is
http://www.mywebsite.com/FF_Supersneaker_Black_Metallica_p/155-157.htm
and I am trying to rewrite it to
http://www.mywebsite.com/FF_Supersneaker_Black_Metallica.html
essentially removing “_p/155-157.htm” and appending .html
The htaccess file I am using to do this is
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule /(.*)/(.*)_p/[^/]*.htm$ /$1$2.html
</IfModule>
But it seems to be failing, Here is the rewrite log I get when going to the page.
255.255.255.255 - - [25/Apr/2012:12:34:43 --0400] [www.mywebsite.com/sid#9b25ed8][rid#9e33c28/initial] (3) [perdir /var/www/test/] strip per-dir prefix: /var/www/test/FF_Supersneaker_Black_Metallica_p/155-157.htm -> FF_Supersneaker_Black_Metallica_p/155-157.htm
255.255.255.255 - - [25/Apr/2012:12:34:43 --0400] [www.mywebsite.com/sid#9b25ed8][rid#9e33c28/initial] (3) [perdir /var/www/test/] applying pattern '/(.*)/(.*)_p/[^/]*.htm$' to uri 'FF_Supersneaker_Black_Metallica_p/155-157.htm'
255.255.255.255 - - [25/Apr/2012:12:34:43 --0400] [www.mywebsite.com/sid#9b25ed8][rid#9e33c28/initial] (1) [perdir /var/www/test/] pass through /var/www/test/FF_Supersneaker_Black_Metallica_p/155-157.htm
I believe it seems like something is wrong with my rule, but I’m not sure what. If anyone can give me some thoughts, I’d appreciate it.
Thank you for any help.
First, look at this:
That path you’re matching against is actually
FF_Supersneaker_Black_Metallica_p/155-157.htmbecause you’re running inside a directory context (from a.htaccessfile). So it’s not going to match anything starting with/…That suggests that what you really want is simply…
…if you want the result to be: