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 2 of 2

Thread: htaccess help

  1. #1
    New to the CF scene
    Join Date
    Nov 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    htaccess help

    Hi all. Can anybody possibly help me with my htaccess file. It's got a problem in there somewhere which is stopping everything from working but for the life of me I can't see where. I'm only doing 2 things: ensuring www is used as the main url, and making search engine-friendly urls. Also if anybody knows how to change the "offers" bit so that I don't have to enter every offer page (rather, it processess any "pos=XX" dynamically) that would be awesome.

    thanks all...

    Options -Multiviews
    RewriteEngine On
    RewriteBase /

    # Force search engines to use www.someurl.co.uk
    RewriteCond %{HTTP_HOST} !^www\.someurl\.co\.uk$
    RewriteRule ^(.*) http://www.someurl.co.uk/$1 [R=301,L]

    # Specify search friendly URLs
    RewriteRule ^top-ten$ /index.php [L]
    RewriteRule ^what-is-it$ /what-is-it.php [L]
    RewriteRule ^contact-us$ /contact-us.php [L]
    RewriteRule ^offer-1$ /offer.php?pos=1 [L]
    RewriteRule ^offer-2$ /offer.php?pos=2 [L]
    RewriteRule ^offer-3$ /offer.php?pos=3 [L]
    RewriteRule ^offer-4$ /offer.php?pos=4 [L]
    RewriteRule ^offer-5$ /offer.php?pos=5 [L]
    RewriteRule ^offer-6$ /offer.php?pos=6 [L]
    RewriteRule ^offer-7$ /offer.php?pos=7 [L]
    RewriteRule ^offer-8$ /offer.php?pos=8 [L]
    RewriteRule ^offer-9$ /offer.php?pos=9 [L]
    RewriteRule ^offer-10$ /offer.php?pos=10 [L]

  • #2
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    This is what I use to force a "www" prefix:

    Code:
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
    I'm not sure if your version is the cause of your problem or not, but I at least like the portability of my version.

    For the second part, I think your syntax is backwards (your match and replacement are reversed). And to get the numbered items into a single line you use a regular expression match instead of the literal string you are trying to match. Try this (untested):

    Code:
    #note: I'm not sure if the question mark needs to be escaped or not, but I went ahead and escaped it...
    RewriteRule ^(offer.php\?pos=[0-9]) offer-1$ [L]
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting


  •  

    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
    •