I’ve been trying and reading a lot to implement a mod_rewrite rule but still have issues with it. I hope anyone can give me a hand in order to make it work properly. Thanks in advance.
First, a specification is needed whereby you specify the format of the link you wish visitors to see then the actual link required for the server to display the intended content.
You have that with accesando/ver_articulo-Redes-sociales-2 => accesando/ver_articulo.php?Redes-sociales-2, however, I would recommend that you delete ver_articulo entirely (because it is only confusing you). Your second “new format” is worse because it introduces a wild file extension which must fail!
Second, code the specification:
RewriteEngine on
RewriteRule ^accesando/([-a-zA-Z]+)$ accesando/ver_articulo.php?$1 [L]
Note: This only uses the latin alphabet without accent marks - if you’re including those in your links, you’ll need to alter the regular expression to include them, too.
Third, you might benefit from reading the mod_rewrite tutorial linked in my signature as it contains explanations and sample code. It’s helped may members and should help you, too.
Wow. Thanks a lot for your help DK. I’m reading your article right now and will be back to you as finish it to see if I can finish this rewrite rule today.
Hope you don’t mind to give me a hand and let me know what I’m missing, your example on the section I mention matched nicely with the things I’m trying to do and the code you showed me.
My first thought in reading your post #5 was that your server does not have mod_rewrite enabled. There are ways for you to check that in the tutorial so I won’t continue in that vein here.
You stated that this code was for a forum. That, to me, implies that there is also other mod_rewrite code at work and, because ORDER of the mod_rewrite statements is critical, you’ll need to show that code (or simply insert my code above before the other code - that should give it priority and force the redirection before your other code manipulates the {REQUEST_URI} variable).
My first thought in reading your post #5 was that your server does not have mod_rewrite enabled. There are ways for you to check that in the tutorial so I won’t continue in that vein here.
Yes, my server has mod rewrite enable.
You stated that this code was for a forum. That, to me, implies that there is also other mod_rewrite code at work and, because ORDER of the mod_rewrite statements is critical, you’ll need to show that code (or simply insert my code above before the other code - that should give it priority and force the redirection before your other code manipulates the {REQUEST_URI} variable).
As I understand now, the order affects the way the rewrite rules apply, that’s why I put the 1st line below RewriteEngine On yours, like this: