Forum Moderators: phranque
What I need is when user / SE goes to:
http://www.example.com/filename.html
To be redirected to:
http://www.example.com/filename/
...so I need to "strip" extension and add slash instead of it :)
I tried with following (but this isn't working):
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^GET\ /[^.]+\.html\ HTTP
RewriteRule ^([^.]+)\.html$ $1/ [R=301]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule . /wordpress/index.php [L]
RewriteRule ^/$ /e/www/ [R]
</IfModule>
# END WordPress
...anyone knows why?
[edited by: encyclo at 1:29 pm (utc) on Jan. 31, 2008]
[edit reason] switched to example.com [/edit]
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^GET\ /[^.]+\.html\ HTTP
RewriteRule ^([^.]+)\.html$ $1/ [R=301]
The second rule - that's WordPress's rule (when I installed WP it was added automatically)
All I am trying to achieve is when address is typed like e.g.
http://www.example.com/filename.html
to be re-written as:
http://www.example.com/filename/
but after that to continue WordPress rule...
Any ideas how to achieve this?
BTW: GREAT FORUM MAN - I FOUND A LOT OF HELPFUL STUFF HERE!
[edited by: encyclo at 1:30 pm (utc) on Jan. 31, 2008]
[edit reason] switched to example.com [/edit]
RewriteRule ^/$ /e/www/ [R]
You appear to have coded the latter function, and if WP doesn't know what to do with the .html-less, slashed URL, then you haven't accomplished anything.
If you phrase your goal in terms of "when someone clicks a link that says 'this', I want 'that' to happen" then this will be easier to discuss -- Start with a link on one of your pages and work forward from there, rather than trying to work from the middle out both ways... A click on a link is where things start.
Jim
In browser address bar someone type:
[webmasterworld.com...]
Can that be "rewritten" as:
[webmasterworld.com...]
...stripped extension and added slash at the end :)
None of the above will work until you edit your pages to publish the new "/somefile" links... The links on your pages define the URL that will be used by the world.
Jim
I want for URL to be rewritten:In browser address bar someone type:
[webmasterworld.com...]
Can that be "rewritten" as:
[webmasterworld.com...]...stripped extension and added slash at the end :)
jdMorgan
That sounds backwards.
jd you always comes across as a clever fellow so i was surprised when you said this sounds backwards. In what way is it backwards?
I actually came across this thread as I was looking to do the same thing for a blog. I thought the guys question in his first post was pretty clear.
At a guess he has moved from blogger to a wordpress setup and he wants all the url's from blogger which have .html extentions to hit the right pages in wordpress which end with a /
It is critically important to have a correct requirements specification before coding. My statements above were intended to elicit a response from the OP, so that the requirements can be ascertained; The code looks correct, therefore I question the requirements.
Jim
The code posted above *should* do what is desired, so that is where the questions come from.
Now I understand that, when I re-read what you posted it all makes sense. Please accept my apologies jd.
In my search to achieve blah-blah.html becoming blah-blah/ I came across the following and found it achieved what I was looking to do.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^([0-9]{4})/([0-9]{1,2})/([^/]+)\.html$ $1/$2/$3/ [QSA,R=301,L]
</IfModule>
Looks a lot more than what 'should' have worked in the OP, granted I never tried it as I misunderstood and thought it wouldn't work.