Jump to content

help with multiple mod rewrites ?


Go to solution Solved by Ch0cu3r,

Recommended Posts

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..

 

 to

 

http://mydomain.com/holiday-deals

http://mydomain.com/international-holidays

 

 

is there a way around it ??

Link to comment
https://forums.phpfreaks.com/topic/283268-help-with-multiple-mod-rewrites/
Share on other sites

  • Solution

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 by Ch0cu3r
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.