Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthordavist11
    • CommentTimeMar 21st 2007
     permalink
    So I have been messing with mod_rewrite to do some URL rewriting on my site. Here is my htaccess file:


    Options +MultiViews
    Options +FollowSymLinks
    AddType x-mapp-php5 .php
    RewriteEngine on
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^www\.trevordavis\.net$ [NC]
    RewriteRule ^(.*)$ http://trevordavis.net/$1 [R=301]

    RewriteRule ^([A-Za-z0-9-]+).htm$ index.php?fa=$1 [L]


    I have my site redirecting properly from http://www.trevordavis.net to http://trevordavis.net.

    The other thing I am trying to do is rewrite URLs like this http://trevordavis.net/index.php?fa=sitemap so that they can be accessed from http://trevordavis.net/sitemap/. Right now, I can only get it to go to http://trevordavis.net/sitemap.htm as you can see in the last line of my htaccess.

    Now I tried this RewriteRule ^([A-Za-z0-9-]+)/$ index.php?fa=$1 [L], but it would not work, and I got a 404 page. I don't really understand why it is not working. I don't know if it something I am doing or something that my host is preventing. Any insight would be awesome. Thanks in advance.
    • CommentAuthorPettyRider
    • CommentTimeMar 21st 2007
     permalink
    The only method I ever need:
    Options +FollowSymLinks
    RewriteEngine on

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?fa=$1 [L,QSA]
    • CommentAuthordavist11
    • CommentTimeMar 21st 2007
     permalink
    hmm i got a 404 error.
    • CommentAuthorPettyRider
    • CommentTimeMar 22nd 2007
     permalink
    then index.php isn't being found. Perhaps is not at the same level as your .htaccess file?
    • CommentAuthordavist11
    • CommentTimeMar 23rd 2007
     permalink
    hmm, no its at the same level, both are at the root.
  1.  permalink
    You can try something like that
    RewriteEngine On
    RewriteRule ^([^/]*)/$ /index.php?fa=$1 [L]


    Cheers, DS
    • CommentAuthordavist11
    • CommentTimeMar 23rd 2007
     permalink
    Hmm that didnt work either. Got a 404 page again. Could this be a setting on the server that I need my host to change?

    BUt it doesnt maker sense that I could rewrite http://trevordavis.net/index.php?fa=sitemap to this http://trevordavis.net/sitemap.htm but not this http://trevordavis.net/sitemap/

    Anyone have any ideas?
    • CommentAuthorknitcore
    • CommentTimeMar 31st 2007
     permalink
    i'm not sure why you'd want to check for '/' at the end--what i do on my sites are grab everything, then at the code level i strip off and leading/trailing slashes.

    for my personal site, i have some really simple rules:

    RewriteEngine On
    RewriteBase /

    RewriteRule ^88/resource(.*)$ /assets-old$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule ^(.*)$ /etomite/index.php?--page--=$1 [L,QSA]

    basically what PettyRider posted. which work fine for me. /about and /about/ both get resolved to the right content, which is fine since they're all virtual pages. and notice that for the first rule (^88/resource(.*)$), i don't need to worry about checking for a / because if it's there, it gets appened to /assets-old. so /88/resource/somefile.gif becomes /assets-old/somefile.gif.

    i don't see why there would be a server issue since rewriting works (in certain cases at least). try removing the domain forwarding first and see if that helps. if it does, then maybe you'll need to work on an alternative solution to forwarding (i.e., use a [L], otherwise rewrite keeps executing.).
Add your comments
    Username Password
  • Format comments as (Help)