Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question htaccess Mod_Rewrite 404 error

    Hi Everyone,

    I am trying my hand at a mod_rewrite, although I keep getting a 404 error and from the url if it did work I would not get the results I am looking for. I want to drop the articledetail.php only and keep everything else or is this just impossible. I am hopeful someone here can help me out.

    Thanks,

    This what I get with the 404 error:

    http://www.articlefinder.info/793/90...-the-Best.html

    This is what I want:
    http://www.articlefinder.info/artid=...-the-Best.html

    Code:
    RewriteEngine on
    # Mod Rewrite
    Options +FollowSymLinks
    #Fix Rewrite
    Options -Multiviews
    Rewritebase /
    RewriteRule ^\.htaccess$ - [F]
    
    RewriteCond %{THE_REQUEST} ^[^/]*/articledetail\.php [NC]
    RewriteRule ^articledetail\.php(.+) $1 [R,L]
    
    #Rewrite Rules and conditions below were already in the script and work.
    RewriteCond %{REQUEST_METHOD} ^PUT$ [OR]
    RewriteCond %{REQUEST_METHOD} ^MOVE$
    RewriteRule ^/author/(.*)\.php /author/$1.nophp
    RewriteRule ^/author/(.*)\.html /author/$1.nohtml
    RewriteRule ^/author/(.*)\.htm /author/$1.nohtm
    RewriteRule ^/author/(.*)\.js /author/$1.nojs

  • #2
    New Coder
    Join Date
    Jul 2011
    Posts
    67
    Thanks
    0
    Thanked 13 Times in 13 Posts
    Sounds like you are misunderstanding the point of what mod_rewrite does (which is REALLY common). It is intended to take a request for one URI and serve some resource from your actual server.

    In your case if Apache receives a request to the server for /author/foobar.php, it would attempt serve up the file /author/foobar.nophp. I'm assuming this isn't actually a file on your server. Assuming you want to achieve the common task of URL's on your site not having file extensions, then you need to flip your view of how it works. At it's most basic you would have something like...

    Code:
    RewriteRule ^/author/(.*)/?$ /author/$1.php
    This will then take requests for /author/foobar and serve the file located at /author/foobar.php, therefore you must then change all URLs on your site to point to the extension less path.

    NB. If you have this code in your .htaccess file, not in a Vhost file, then the very first forward slash doesn't want to be there.

  • #3
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Cags,

    Thanks for taking a look! The reason I want to drop the articledetail.php is just to cleanup the look. I want to keep the following because Google uses them as URL parameters's and by me defining the effect on the content my crawled pages went from 26 to 1,059 in one day. Today it is 1,103 but I understand that's not page ranking at least they are indexed. Maybe it would be best not to mess with it.

    Any other input is welcomed!

    Regards,

    Keep: artid=793&catid=90&title=


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •