mod_rewrite help

PythonPython Forum LeaderThe Royal RAM
im trying to make my site's dynamic url's search engine friendly But Im having a bit of a problem...

Here is what is in my .htaccess file:
RewriteEngine On
RewriteRule ^(tutorials)/$ /tutorials.php [L]
RewriteRule ^(tutorials)$ /tutorials.php [L]
RewriteRule ^tutorials/(.*)/$ /tutorials.php?c=$1 [L]
RewriteRule ^tutorials/(.*)$ /tutorials.php?c=$1 [L]
RewriteRule ^tutorials/(.*)/(.*)/$ /tutorials.php?c=$1&t=$2 [L]
RewriteRule ^tutorials/(.*)/(.*)$ /tutorials.php?c=$1&t=$2 [L]

This are what I want it to do:

domain.com/tutorials.php >> domain.com/tutorial - this works
domain.com/tutorials.php?c=4 >> domain.com/tutorial/4 - this works
domain.com/tutorials.php?c=4&t=5 >> domain.com/tutorial/4/5 - this doesnt work

The one which doesnt work works fine when its not uring mod_rewrite therefore the coding must be right...
Any ideas?

Thanks

The Royal Ram

Comments

  • DanDan Senior Member The Royal RAM
    well try this

    RewriteRule tutorials/(.*)/(.*)/(.*)/(.*)/$ /tutorials.php?$1=$2&$3=$4 [L,NC}

    It will change it to domain.com/tutorials/c/4/t/5/
  • ArestiaArestia Member NAT Warrior
    i would use conditions there as you might want other mod_rewrite formating different than this.
    Options +FollowSymLinks
    RewriteEngine on
    
    RewriteCond %{REQUEST_URI} ^/tutorials/
    RewriteRule ^(.*)/ /tutorials\.php  [L]
    
    RewriteCond %{REQUEST_URI} ^/tutorials/(.*)/
    RewriteRule ^(.*)/ /tutorials\.php?c=%1  [L]
    
    RewriteCond %{REQUEST_URI} ^/tutorials/(.*)/(.*)/
    RewriteRule ^(.*)/ /tutorials\.php?c=%1&t=%2  [L]
    

    this should do this:
    domain.com/tutorials.php >> domain.com/tutorials/ - this works
    domain.com/tutorials.php?c=4 >> domain.com/tutorials/4/ - this works
    domain.com/tutorials.php?c=4&t=5 >> domain.com/tutorials/4/5/ - this doesnt work
    Arestia Design Studios / Synapse Corporate Solutions
    Daniel L. Rust - Lead Architect
    Seattle, WA
Sign In or Register to comment.