Forum Moderators: phranque
#Giving all php pages htm extension
RewriteRule ^(.*)\.htm$ $1.php [L]
I am using above to redirect my all php pages in some category to .htm extension but the problem is that I have eleven (11) categories and want to redirect 10 categories sub pages to .htm but not a one mean if I have categories like
apple
banana
orange
mange
onion....
so I want to redirect all fruits except onion
Given example above is just a example not a real category
please reply fast
I will be thankful to all who will help me in making a right query
[edited by: jdMorgan at 6:18 pm (utc) on June 9, 2009]
[edit reason] example.com [/edit]
#Redirect sub pages of category having extension of .php to .htm
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /cateogry/pagename.php[?]?[^\ ]*\ HTTP/
RewriteRule ^category/pagename.php$ http://www.example.com/category/pagename.htm? [R=301,L]
#Giving all php pages htm extension
RewriteRule ^(.*)\.htm$ $1.php [L]
-------I am using my query like the above but
#Redirect sub pages of category having extension of .php to .htm
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /mango/pagename.php[?]?[^\ ]*\ HTTP/
RewriteRule ^mango/pagename.php$ http://www.example.com/mango/pagename.htm? [R=301,L]
#Giving all php pages htm extension
RewriteRule ^(.*)\.htm$ $1.php [L]
----The above category which is mango I want all of its pages to redirect .html version when anyone open its .php extension page
Now I want to do some thing like that in a single query that when anyone ask for the page present in onion category then it will not redirect it to .html version like if visitor ask for
www.example.com/allcategoies/pagename.php then redirect to
www.example.com/allcategoies/pagename.html
BUT
in all categories except ONION... like if ask for
www.example.com/onion/pagename.php then I do not want it to redirect to .html version
www.example.com/onion/pagename.php
I want to do all this in single query so is it possible?
Please reply me waiting for it
Thanks in Advance
# Redirect sub pages of categories ([i]except onion[/i]) having extension of .php to .htm
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+)/([^.][b]+)\.p[/b]hp[?]?[^\ ]*\ HTTP/
[i]RewriteCond %1 !=onion[/i]
RewriteRule ^([^/]+)/([^.][b]+)\.p[/b]hp$ http://www.example.com/$1/$2.htm? [R=301,L]
Jim
now I just place my real category name in place of onion but it does redirect the pages of that category. I just remove the sign "!" before the "=" sign which I thinks give the mean not equals to but after removing "!" sign it does not redirect any other category pages including my ONION category pages .... so now what is the best solution sir!
Thanks for great help
Now waiting for another reply
Check the spelling of the string that you substituted for "onion." It must be exactly correct, including uppercase/lowercase, and it must not start with, end with, or contain a slash.
The problem is not likely with the code. The problem is likely that your requirements have not been stated clearly here. That is, the code meets your requirements as I understand them from what you have written here, but what you have written here does not precisely describe your actual requirements. (This code is quite trivial, but describing and understanding exactly what you want the code to do is not trivial. This is a very common problem in the software world.)
Jim
Hey I have another problem in my web so can you please figure me out with that ? If you agree then I paste my problem else will be very thankful to you and never forget you man