Jump to content

Combine .htaccess Rules


amwd07

Recommended Posts

Please can some one help me to combine these rules & get them to work together?

 

Options +FollowSymLinks

RewriteEngine on

 

#Removes trailing slash from URL

#RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]

 

RewriteRule ^([^.]+)$ /dynamic.php?feature=$1 [L]

#RewriteRule ^([^.]+)/([^.]+)$ /dynamic.php?feature=$1&section=$2 [L]

 

First question is how do I get the last 2 RewiteRules to work together.

currently it only works with one query if I uncomment the 2nd that also works but disables the first?

 

 

Even if I can get the above to work correctly by removing the trailing slash above the rule below fails

 

RewriteRule ^dining/([^.]+)-([^.]+)\.php$ dining.php?county=$1&town=$2 [L]

 

I can't win anyone any idea's?

Link to comment
https://forums.phpfreaks.com/topic/103943-combine-htaccess-rules/
Share on other sites

I have been looking through this topic & thought i had come up with the solution below

but still pulling my hair out with this one  ???

 

Options +FollowSymLinks

RewriteEngine on

 

#Removes trailing slash from URL

RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]

 

RewriteRule ^([^.]+)$ /dynamic.php?feature=$1 [L]

#RewriteRule ^([^.]+)/([^.]+)$ /dynamic.php?feature=$1&section=$2 [L]

 

////// Now the directory below needs to work off a spearte rule, but he above still effects this ////

I thought the RewriteCond would seperate them not sure if i need to use [OR] somewhere?

 

# Force trailing slash on directories  (This only works if I take out the RewriteCond above?)

RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^(.+[^/])$ $1/ [R,L]

 

RewriteRule ^dining/([^.]+)-([^.]+)\.php$ dining.php?county=$1&town=$2 [L]

Archived

This topic is now archived and is closed to further replies.

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