I have the following rule that allows me to create multiple categories in the URL
, without needing to write the categories in my .htaccess
, for example:RewriteRule ^mundial/(...
But directly from the following rule:
RewriteRule ^(.*)/([^/]+/?)$ detail.php?id=$2&categories=$1
RewriteRule ^(.*)/([^/]+/?)$ detail_one.php?id=$2&categories=$1
I can have a number of categories in the URL, for example:example.com/categoria/mundial/otras/muchasmas/url-del-post/
Now my problem is, that I have individual product details, created by individual files detail.php
, detail_one.php
among others.
Which only works for me one of the rules .htaccess
, that is, I have to deactivate #
one of them, so that the detail of the products of the file detail.php
shows the details and to show the detail of the file detail_one.php
I have to deactivate the rule .htaccess
of the filedetail.php
How can I keep the same layout for multiple categories, but the same rule allows me to add more than one, for different news details?
As we've discussed in the chat, you can't have the same rule repeated and expect it to redirect you to different phps. The urls should have something different to distinguish them by. Something for which it begins or ends, for example. If not, what it will do is always process the first rule of the two.
So, we will make the pages that go to detail have this form:
midominio.com/categoria1/categoria2/mi-url
. While those that go to detail_one will start with a 1 in front:midominio.com/1/categoria1/categoria2/mi-url
If you wanted to put the 1 at the end
midominio.com/categoria1/categoria2/mi-url/1
, you could use: