1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Re write help please

Discussion in 'Apache' started by Jim bob 9 pants, Nov 23, 2005.

  1. #1
    Can I make

    visitdevonandcornwall.com/DevonAccommodation.php

    look like

    visitdevonandcornwall.com/Devon/Accommodation

    loosing the .php as well, using re writes, if so how?

    Any ideas would be great
     
    Jim bob 9 pants, Nov 23, 2005 IP
  2. emeraldibex

    emeraldibex Peon

    Messages:
    2
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    RewriteRule ^Devon/Accommodation$ DevonAccommodation.php
     
    emeraldibex, Nov 23, 2005 IP
    Jim bob 9 pants likes this.
  3. Jim bob 9 pants

    Jim bob 9 pants Peon

    Messages:
    890
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you so much
     
    Jim bob 9 pants, Nov 23, 2005 IP
  4. Jim bob 9 pants

    Jim bob 9 pants Peon

    Messages:
    890
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #4
    That is not working an ideas please

    Nintendo has written a great crib here but has anyone know of areal numpties advice site?
     
    Jim bob 9 pants, Nov 24, 2005 IP
  5. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Do you need just this URL or all URLs like this one (capitalized words become directories)?
     
    J.D., Nov 24, 2005 IP
  6. Jim bob 9 pants

    Jim bob 9 pants Peon

    Messages:
    890
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Not all, but a whole bunch.

    also I want to do this

    visitdevonandcornwall.com/guesthouse1.php

    in to

    visitdevonandcornwall.com/devon-cornwall/guest-house

    I assume mod rewrites are my easiest option.

    Jamie

    That is my current .htacess file, if that helps
     
    Jim bob 9 pants, Nov 24, 2005 IP
  7. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I just checked your /Devon/Accomodation URL and it comes back with a 300 (multiple choices) response. Make sure you end your re-write line with [L] for this rule. For example:

    RewriteRule ^Devon/Accommodation/?$ DevonAccommodation.php [L]

    If you want some generic mechanism, you can use something like this:

    RewriteRule ^([A-Z][a-z]+)/([A-Z][a-z]+)/?$ $1$2.php [L]

    This will rewrite things like /My/Folder to /MyFolder.php. Just keep in mind that this will work on *all* capitalized URLs. You might want to prefix it with something like /acm/... to distinguish from other URLs.

    J.D.
     
    J.D., Nov 24, 2005 IP
  8. Jim bob 9 pants

    Jim bob 9 pants Peon

    Messages:
    890
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #8
    RewriteRule ^Devon/Accommodation/?$ DevonAccommodation.php [L]

    That is not working for some reason !!!

    EDIT

    This seems to work - RewriteRule ^Devon/Accommodation/?$ /DevonAccommodation.php [L]
     
    Jim bob 9 pants, Nov 24, 2005 IP
  9. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #9
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)$ $1.php [L]

    Would be the easiest way, having them all go from from WhatEver.php to WhatEver/

    I'm not sure if you can add a / in to it if the script doesn't have that, unless you use a line for every script.

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^Devon/Accommodation$ DevonAccommodation.php [L]
    RewriteRule ^devon-cornwall/guest-house$ guesthouse1.php [L]
     
    Nintendo, Nov 24, 2005 IP
  10. Jim bob 9 pants

    Jim bob 9 pants Peon

    Messages:
    890
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Thank you Nintendo!!

    As I have deep links to my pages, where the URL will now change, should I be putting a 301 redirect in place??
     
    Jim bob 9 pants, Nov 24, 2005 IP
  11. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #11
    If old URLs are indexed in search engines, then yes. Both original and new links will work, but the redirect gets rid of duplicate content. Only change to the code is

    [L] being changed to [R=301,L] and using the full URL

    RewriteRule ^whatever.php$ http://www.domain.com/whatever [R=301,L]

    I'm not sure if that'll both make the new URL work and also redirect to it.
     
    Nintendo, Nov 24, 2005 IP
  12. Jim bob 9 pants

    Jim bob 9 pants Peon

    Messages:
    890
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Jim bob 9 pants, Nov 24, 2005 IP
  13. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #13
    Does it have

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /

    with it?

    I'm not sure what causes that error. That's the first time I've seen that!
     
    Nintendo, Nov 24, 2005 IP
  14. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #14
    That would happen if RewriteBase is missing. Adding slash in front works just as fine.

    There's no need for this, really. This rule will rewrite all capitalized URLs:

    RewriteRule ^([A-Z][a-z]+)/([A-Z][a-z]+)/?$ /$1$2.php [R,L]

    That is, /Devon/Accomodation will be rewritten as /DevonAccomdation.php.

    J.D.
     
    J.D., Nov 24, 2005 IP
  15. Jim bob 9 pants

    Jim bob 9 pants Peon

    Messages:
    890
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Jim bob 9 pants, Nov 25, 2005 IP
  16. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #16
    Only way I know of for doing 301 is changing a URL to another URL that's not the original URL. Not redirecting the original URL to the new mod_rewrite URLs. Original URLs always work with the new URLs when you use mod_rewrite. You just don't want links pointing to both types of URLs!
     
    Nintendo, Nov 25, 2005 IP
  17. Jim bob 9 pants

    Jim bob 9 pants Peon

    Messages:
    890
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #17
    Thanks nintendo
     
    Jim bob 9 pants, Nov 25, 2005 IP
  18. Jim bob 9 pants

    Jim bob 9 pants Peon

    Messages:
    890
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #18
    Jim bob 9 pants, Nov 25, 2005 IP
  19. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #19
    For images, using the full URL, or if there's not a / right after the first " try adding the / after it.
     
    Nintendo, Nov 25, 2005 IP
  20. Jim bob 9 pants

    Jim bob 9 pants Peon

    Messages:
    890
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #20
    I must be doing something wrong as that is not helping.

    Anyone have any ideas on how to get around this!!:)
     
    Jim bob 9 pants, Nov 27, 2005 IP