Forum Moderators: phranque

Message Too Old, No Replies

htaccess redirect problem

trying to remove part of directory path

         

cheaperholidays

1:47 pm on Jun 28, 2006 (gmt 0)

10+ Year Member



We are trying to redirect example.com/late-deals/2006/06/25/cyprus-holiday-deals
to
http://www.example.com/late-deals/holidays/cyprus-holiday-deals

and this is what we have in our htaccess file. Does anyone have any ideas what we are doing wrong?

<Files .htaccess>
order allow,deny
deny from all
</Files>

RewriteRule ^/?late-deals/([0-9]{4})/([0-9]{2})/([0-9]{2})/([-a-z]+)$ /late-deals/holidays/$4 [R=301,L]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /late-deals/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /late-deals/index.php [L]
</IfModule>

# END WordPress

[edited by: jdMorgan at 2:47 pm (utc) on June 28, 2006]
[edit reason] No URLs, please. See TOS. [/edit]

jdMorgan

3:36 pm on Jun 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure what doesn't work about your code, and more information would be helpful. But here's how I would do it:

Redirect example.com/late-deals/2006/06/25/cyprus-holiday-deals
to
http://www.example.com/late-deals/holidays/cyprus-holiday-deals

 RewriteRule ^late-deals/([0-9]{4})/([0-9]{2})/([0-9]{2})/([a-z\-]+)$ http://example.com/late-deals/holidays/$4 [R=301,L]

It's often very helpful to post the following things:

What happens when you test your code?
How do these results differ from your expectations?
Do you get an error message in the browser?
If so, what information appears in your server error log regarding this error?
How about the server access log? -- Is there anything related to the error in it?

This case is complicated by having the WordPress code in there -- The RewriteBase caught my eye, and I'm not sure if that might be interfering with your new code. But try the above modified code, and see if it helps.

Jim