cyber_alchemist Posted October 25, 2013 Share Posted October 25, 2013 I have been stuck with this for quite a while now.. i have this rewrite rule for now.. #RewriteCond %{THE_REQUEST} \ /trip\.php\?url=([^&]+\) RewriteRule ^([^/]*)\.html$ /trip.php?url=$1 [L] but now i want this one as well so as any page in .php extention would be converted to .html extention such as .. RewriteRule ^(.*)\.html$ $1.php [nc] also i was working with few other pages and i need these queries to be converted as well.. http://mydomain.com/tours.php?holiday-deals=variable http://mydomain.com/tours.php?international-holidays=variable to http://mydomain.com/holiday-deals http://mydomain.com/international-holidays is there a way around it ?? Quote Link to comment https://forums.phpfreaks.com/topic/283268-help-with-multiple-mod-rewrites/ Share on other sites More sharing options...
Solution Ch0cu3r Posted October 25, 2013 Solution Share Posted October 25, 2013 (edited) For the following rules to work RewriteRule ^([^/]*)\.html$ /trip.php?url=$1 [L] RewriteRule ^(.*)\.html$ $1.php [nc] You need some form of unique identifier in your url For example if domain.com/las-vagas.html should request trips.php?url=las-vagas and domain.com/trips.html should request trips.php how is the server going to know what url matches which rule? Both will match any url that contains .html and the first rewrite rule will always be used. For viewing trips to las-vagas I'd have urls like domain.com/trips/las-vagas.html To see trips.php I'd have I'd have urls like domain.com/trips/. The the following rules will match these urls and make the nessecary request #Matches domain.com/trips/las-vegas.html RewriteRule ^trips/([^/]).html trips.php?url=$1 [L] #Matches domain.com/trips/ RewriteRule ^([^/])/? $1.php [L] Edited October 25, 2013 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/283268-help-with-multiple-mod-rewrites/#findComment-1455391 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.