#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    13
    Rep Power
    0

    Simple mod_rewrite


    Hi

    How can I simplify the mod_rewrite:

    Code:
    RewriteRule ^picturi~peisaj-rural~([0-9]+)$ index.php?page=picturi&filtru=subiecte-detaliate&tip=peisaj-rural&gal=$1 [QSA,L]
    RewriteRule ^picturi~peisaj-urban~([0-9]+)$ index.php?page=picturi&filtru=subiecte-detaliate&tip=peisaj-urban&gal=$1 [QSA,L]
    RewriteRule ^picturi~rauri~([0-9]+)$ index.php?page=picturi&filtru=subiecte-detaliate&tip=rauri&gal=$1 [QSA,L]
    
    RewriteRule ^picturi~abstract~([0-9]+)$ index.php?page=picturi&filtru=subiecte-generale&tip=abstract&gal=$1 [QSA,L]
    RewriteRule ^picturi~altele~([0-9]+)$ index.php?page=picturi&filtru=subiecte-generale&tip=altele&gal=$1 [QSA,L]
    RewriteRule ^picturi~animale~([0-9]+)$ index.php?page=picturi&filtru=subiecte-generale&tip=animale&gal=$1 [QSA,L]
    RewriteRule ^picturi~compozitie~([0-9]+)$ index.php?page=picturi&filtru=subiecte-generale&tip=compozitie&gal=$1 [QSA,L]
    Idea is not to show in the address bar "subiecte-detaliate" and "subiecte-generale", that why I use to insert manually each category in htaccess.
    It's there a simple way?

    Thanks
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    17
    Rep Power
    0
    That looks tough at first glance, since there's no lookup for whether or not a given url is in "subiecte-detaliate" or "subiecte-generale".

    However, all is not lost, depending on your access to the web server. Assuming you can modify your vhost, you can use the rewrite map functionality in Apache to create a lookup table of urls to categories, and then should be able to do this in a single rewrite rule.

    You may even be able to pull the map data out of an SQL query if that is where the articles and categories are defined.

    Documentation Link: http://httpd.apache.org/docs/current/rewrite/rewritemap.html

IMN logo majestic logo threadwatch logo seochat tools logo