Hope this ends up in the right forum! Sorry if it didnt!
Ok, so, this is my problem…
Some time ago a moved a static website to Wordpress…
…and I didnt wanna put a permanent redirect on all old urls (and wanted it to look like static webpages and have the same extension on both posts and pages) so I installed a plugin that added .html in the end of wordpress pages. (http://www.introsites.co.uk/wordpress/html-on-pages-plugin.html)
Some pages though, uses pagination when displaying posts…and on those I’ve ended up with urls that looks like this:
So I either need a rewrite rule that moves the .html extension to the end of the url for the pages that have pagination.
But I rather clean it all up and just deactivate the plugin and just take out the .html from all urls… (because they dont really do much do they!?)
But then I need a permanent redirect that redirects all the old urls that ends in .html to none .html which I could probably google my way to but what about the www.mysite.com/news-arhive.html/page/2 type urls?
Do I need to make a redirect for each of those urls?
It sounds like what you’re trying to achieve should be easy (WP is good with title-based redirections) but your plugin is mucking things up. POST your current .htaccess if you expect help, though, and be prepared to remove that plug-in 'cause it’s messing with your query string (or something).
It’ll probably help to SEE some old URIs (with their query string) and what you want to see now.
I fear that ScallioXTX is correct as messing about with links created by a CMS is the same as messing with how the CMS handles those requests. In other words, if you change those links, you MUST change the modules that handle those links. With the way that all CMSs are “spaghettified,” you’re in for a tough time.
As for the “normal” insertion of a file in a directory slot in the path/to/file, you’ll need the Options +MultiViews to serve the directory (file). I keep away from that like poison as it confuses the situation with the links.
In other words you’re not using the .htaccess at all for the redirects (well, except for routing everything to index.php), but just the wordpress code?
If so, I think you’d better head over to our Wordpress forum and ask your question there
Thanks for not taking offence. I DO go off on things like that - justifiably so! A webmaster should NOT be using code he/she does not understand. It’s obviously not personal, it just gets my tidy whities in a twist! Anyway, I needed that reminder to create Rant #4 and was able to give it a test!
It upsets me GREATLY to see someone making tests repeatedly (as if expecting a different result EVERY @#$% time) so, yes, get rid of the <IfModule> wrappers. If you used those on my server, you’d be GONE (for wasting a valuable resource).
[rant #4][indent]The definition of an idiot is someone who repeatedly does the same thing expecting a different result. Asking Apache to confirm the existence of ANY module with an <IfModule> … </IfModule> wrapper is the same thing in the webmaster world. DON’T BE AN IDIOT! If you don’t know whether a module is enabled, run the test ONCE then REMOVE the wrapper as it is EXTREMELY wasteful of Apache’s resources (and should NEVER be allowed on a shared server).[/indent][/rant 4]
The RewriteBase directive is designed to UNDO a mod_alias Redirect. Where is it in your .htaccess?
The leading / in the redirect is also problematic as it causes Apache to look at its ROOT directory for the index.php file before going to your %{DocumentRoot}. Because your .htaccess is IN your DocumentRoot, the / is superfluous, too.
As for the regex on that redirection, take your pick between ScallioXTX and my versions - there is VERY little to differentiate them, only the dot character after .html. If there is ANY possibility of having that dot character, use ScallioXTX’s version.
Ok, so I dont need the <IfModule> …and the rewrite base you also marked red, dont need that either?
And yes, I just want o get rid of the .html extension, I’m keeping the same site structure. With maybe a few exceptions but then I was just gonna put a rewrite on each url in question.
Yes, it does! However, there shouldn’t be a second dot character BECAUSE MultiViews is putting the filename in a directory position in the path. The objective of the $2 is to pick-up the remaining garbage with either will do. While I prefer the SLIGHTLY more restrictive ([^.]*), the :kaioken: EVERYTHING :kaioken: atom will work for the second filename case, too (which should not be necessary - as per his example - but …).
I would advise a test server to NOT muck-up your PR while sorting this out!
I need to create a new RANT for those who insist on testing the existence of a module in .htaccess. In this case, you’re testing TWICE for every request! GET RID OF THOSE <IfModule> … </IfModule> WRAPPERS! They’re meant to protect the CLUELESS from 500 errors when the module is not there. If you are a webmaster, KNOW whether it’s there and STOP THE SENSELESS TESTING!
BEFORE redesigning your website, I would hope that you assessed what you have, what you want to preserve and where you’re going. You have ~500 existing links that you want to preserve (for PR) so you need to retain their filenames SOMEHOW. Whether that’s in a RewriteMap or a PHP script simulating a RewriteMap, it’s a matter of whether you have access to the server configuration file. You MAY be able to circumvent the RewriteMap IF (and ONLY IF) your new “file” names are identical to the old as you won’t have to do anything at all! Okay, maybe just strip the .html off the filename. THAT is why you need to do this BEFORE redesigning your website.
[COLOR="Red"]<IfModule mod_rewrite.c>[/COLOR]
RewriteRule ^old-url\\.htm$ /info/new-url.html [R=301,L]
[COLOR="Red"]</IfModule>[/COLOR]
# BEGIN WordPress
[COLOR="Red"]<IfModule mod_rewrite.c>[/COLOR]
RewriteEngine On
[COLOR="Red"]RewriteBase /[/COLOR]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . [COLOR="Red"]/[/COLOR]index.php [L]
[COLOR="Red"]</IfModule>[/COLOR]
# END WordPress
So, {What’s the ‘So’ for?} I have 3 (or 2 really) types of URLs that gonne change when I deactivate the plugin and change the permalink structure for the posts:
[indent]Okay, strip .html is simple and … ARGH … strip embedded .html from a MultiViews link! DOUBLE ARGH! Okay, that can ALL be done with a simple substitution RewriteRule, e.g.,