Mod rewrite for urls not working?

hey guys thanks for taking the time to look over my problem and help out!

Mod rewrite used to work on my website but it no longer is working after some time i am not sure if the original htaccess was replaced by mistake or what but it is no longer working.

This is my current htaccess file

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\\.htm$ $1.php [L]

my urls look like this with out the rewrite

www.domain.com/index.php?done=mypage.php

and i want them to look like this how they used to with the rewrite

www.domain.com/mypage.htm

hopefully someone here knows what i am doing wrong thanks for your time!

can you show me what a 301 looks like code wise for say

domain.com/pagename.htm

make the above one redirect to

domain.com/newpagename

so the new page has no extension and would be a wordpress page?

if i can understand based of your example i can create the rest for my other pages as well thanks dklynn

i sent you a PM i have been reading your articles and doing some testing for the past while i will wait to hear back from you but i think i am making some progress

raven,

WELCOME to SitePoint’s Apache forum.

How does $1.php get to /index.php?done=mypage.php? What mod_alias redirection is being undone by the RewriteBase statement? Argh!

Okay, what could have gone wrong? First, can you confirm that mod_rewrite is still working (try the test in my signature’s tutorial). After that, then change the .htaccess to:

RewriteEngine On
[COLOR="LightGray"]RewriteBase /[/COLOR]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)\\.htm$ $1.php [L]

[COLOR="Magenta"]RewriteCond %{REQUEST_URI} !^index\\.php$[/COLOR]
RewriteRule ^(.+)\\.php index.php?done=$1 [L]

Regards,

DK

raven,

That’s all in my signature’s tutorial - except WordPress and that will depend upon which of their options you select. Just put your code (there ARE examples in the tutorial) before the WP code and you’ll be set.

Regards,

DK

with the new rewrite when i click links that are like

www.domain.com/pagename.htm

they load but give me a page not found

the site doesnt run on a cms but i was also wondering if i installed and set up wordpress do u think i could 301 the urls and pass google page rank ? to the new pages so google wont tank my seo rating

raven,

Sorry, noobie error in my code above. PLEASE add the “loop ender” RewriteCond statement to get to your index.php without looping.

A CMS will add something like the second mod_rewrite block (without the .php extension) so I’m sure that you can do that (save Google page rank) but ONLY IF you preserve the original link (and redirect that correctly). IMHO, though, you’d be better off to R=301 those .htm pages to the correct links within your DMS (and WP does have a nice “use the title” feature which should prove more valuable than preserving the PRs).

Regards,

DK

raven,

There was no question in the PM. However, you really should post your questions here.

Regards,

DK