Forum Moderators: phranque
What Im tring to do is rewrite urls that have a folder that contains the word benidorm to "existing folders" without using RewriteMap because my hosting provaider doesnt allow it.
The problem is not with RewriteCond but with the actual RewriteRule, I have no idea how to rewrite /benidorm_restaurants/ to /benidorm-food/ or /deportes_benidorm/ to /benidorm-sport/ in a general way so that if I add a new folder, and therefor new content to the website, this rule would trigger and rewrite the URL.
All this is due to a languaje issue, I want both /benidorm_deportes/ and /benidorm_sport/ to rewrite to /benidorm-deportes/.
Any Idea?
My code in htaccess is ( so far... )
The First Two rules work Ok... its the Base Folders issue...
#Article
RewriteCond %{REQUEST_URI} /a/.*
#RewriteBase /article/.*
RewriteRule -([^/]+)-([^/]+)-([^/]+)-([^/]+)-([^/]+)\.html$ /include/article.php?port=$1&cat=$2&subcat=$3&id=$4&lang=$5 [QSA,L]
#Content
RewriteCond %{REQUEST_URI} /c/.*
#RewriteBase /content/.*
RewriteRule -([^/]+)-([^/]+)-([^/]+)-([^/]+)\.html$ /include/article.php?port=$1&cat=$2&subcat=$3&lang=$4 [QSA,L]
#base folders
RewriteCond %{REQUEST_URI}!/c/.* [OR]
RewriteCond %{REQUEST_URI}!/a/.* [OR]
RewriteCond %{REQUEST_URI} /*_benidorm/.* [OR]
RewriteCond %{REQUEST_URI} /benidorm_*/.*
RewriteRule (.*)\.html /index.php
Thx in advanced!
All this is due to a language issue, I want both /benidorm_deportes/ and /benidorm_sport/ to rewrite to /benidorm-deportes/.
RewriteRule ^benidorm_(deportes¦sport)/$ /benidorm-deportes/ [L]
In addition to the errors, it looks like the code you're using is far more complicated than it needs to be. However, it is difficult to determine how to improve it without knowing what your URL-set looks like.
Jim
Basiclly my URLS look like this /c/benidorm_noche/bares_benidorm-1-103-1-es.html and /a/restaurantes_benidorm/restaurante_mamma_leone_benidorm-1-102-4-1-es.html
But I also have "base folders" that are called /benidorm-deporte/ for example, your example works Ok for the existing folders, but how could I create a rule to rewrite URLs automaticlly when a new folder is created in the structure of the web? Like /benidorm_whatever/ or /whatever_benidorm/?
Is this posible?
Thx again!
I have no idea how to rewrite /benidorm_restaurants/ to /benidorm-food/ or /deportes_benidorm/ to /benidorm-sport/ in a general way so that if I add a new folder, and therefor new content to the website, this rule would trigger and rewrite the URL.
As for the "content" and the "article" rules, you'll probably need to make a complete list of all of the URL roots and all of the corresponding script paths that they need to be mapped to, and work from that.
This looks like a project that is really too big for a forum thread. All I can really suggest is that you change your existing rules like this to make them much more efficient:
#Content
RewriteRule ^c/.*-([^-]+)-([^-]+)-([^-]+)-([^.]+)\.html$ /include/article.php?port=$1&cat=$2&subcat=$3&lang=$4 [QSA,L]
Jim