301 rewrite rule

Florian,

I hope you changed that to the ([a-z_]+) that I gave in my last code. It makes a difference as the - was replaced with _ so the final redirection (from date to blog) will work.

Yes, put my code BEFORE the CMS’s code so it gets the blog/yadda_yadda as the {REQUEST_URI} string. Please note that the R=301 will force the blog/yadda_yadda to be displayed, too (is it being displayed?).

Of course, the code will not work if your links are not limited to lowercase letters and -'s (or _'s). I only used those sets of characters because that’s what you gave in your first post.

Is your CMS expecting blog/yadda-yadda? If it’s a blank page (check for lack of output by viewing the source), it’s likely an error in the PHP code - or failure to find the record in the database.

Regards,

DK

it looks like its not redirecting. When I put the url in like for example www.domain.com/2010/08/28/cats-land-another-top-20-recruit-for-2010/ … the browser ‘thinks’ for a few seconds and then a blank page, which is also blank when i view source.

yes, i did use the latest code that you included. ([a-z_]+)

this is in an otherwise empty htaccess file? I know that the server work because I tested that earlier by following the test tutorial.

Florian,

Whoops! Not quite true! There were also digits in the capture string! Please modify as follows:

That’s twice I missed something in your “specification.” Mea culpa!

Regards,

DK

still blank.

this is the exact code that I am using


RewriteEngine on
RewriteRule ^(.*)-(.*)$ $1_$2 [N]
RewriteRule ^\\d{4}/\\d{2}/\\d{2}/([a-z0-9_]+)/ index.php/blog/$1 [R=301,L]

I am using this test post still


http://www.domain.com/2010/08/28/cats-land-another-top-20-recruit-for-2010/

I manually changed it to the correct url just to ensure that its actual there and that i can access that url.


http://www.dom.com/index.php/blog/cats_land_another_top_20_recruit_for_2010/

me adding that index.php before the blog couldnt mess anything up could it? All my ‘new’ posts have domain.com/index.php/blog

Do you guys have any ideas why it’s not working? I have also noticed, when I use the rewrite htaccess file, that some of my js files do not work?

Florian,


RewriteEngine on
RewriteRule ^(.*)-(.*)$ $1_$2 [N]
RewriteRule ^\\d{4}/\\d{2}/\\d{2}/([a-z0-9_]+)/ [COLOR="Red"]index.php/[/COLOR]blog/$1 [R=301,L]

That’s a big faux pas! WHY would you put a file within the path part of a URI? It’s possible but you would then have to enable MultiViews and that’s a major problem.

I’m sure that your CMS installed some mod_rewrite code in your .htaccess file - just leave that AFTER the code shown above.

Regards,

DK

the cms is expressionengine and for some reason they always have the index.php at the end of the domain. it’s a default. there is a way to get rid of it though with an extension, I might do that anyway, as it doesnt look very pretty with the index.php

I successfully removed the index.php with some regex code.

this is what I am using


RewriteEngine On

RewriteBase /

RewriteCond %{THE_REQUEST} !^POST
RewriteRule ^site/?(.*)$ /$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

not sure how the rewrite rules that we were trying to come up with in this post, would fit in with that.

Florian,

I’m afraid that I don’t mess with expressionengine and they don’t mess with me! :kaioken:

Take a look at MultiViews (search at Apache.org) to see what’s going on with a file in the path.

Regards,

DK

interesting. I think i sort of understand. Let me post over at the EE forum. maybe somebody ran into this same issue before.