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 5 of 5
  1. #1
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,172
    Thanks
    19
    Thanked 65 Times in 64 Posts

    .htaccess problem

    I have this in my .htaccess
    Code:
    RewriteEngine On
    RewriteRule /resorts/([A-Z]+) /resort-info.php?resort=$1 [PT,L]
    the file is in a folder on the domain called /new/

    I expected that when I type in www.mydomain.com/new/resorts/Algarve to get directed to http://www.mydomain.com/new/resort-i...resort=Algarve, but I get a 404. Not sure what the problem is.

  • #2
    Regular Coder
    Join Date
    Oct 2004
    Posts
    356
    Thanks
    0
    Thanked 16 Times in 16 Posts
    You shouldn't have a / at the start and A-Z only matches uppercase.

    I also added /? so you can have an optional trailing slash (you may want to remove this) and ^ and $ to stop people adding extra stuff before and after the matched part (/new/ isn't included in any matching as long as the .htaccess file is in the /new/ directory).
    Code:
    RewriteEngine On
    RewriteRule ^resorts/([A-Za-z]+)/?$ /resort-info.php?resort=$1 [PT,L]
    You probably don't need the PT flag, but you might.

  • #3
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,172
    Thanks
    19
    Thanked 65 Times in 64 Posts
    Thats great but now my css and images dont work.

  • #4
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,172
    Thanks
    19
    Thanked 65 Times in 64 Posts
    Sorted those out but its not liking it if theres a space in the name eg /resorts/Costa%20Blanca

    Code:
    RewriteEngine On
    RewriteRule ^resorts/([A-Za-z0-9\%\_]+)/?$ /new/resort-info.php?resort=$1 [PT]
    RewriteRule ^resorts/([A-Za-z0-9.\.\-\_]+)?$ /new/$1 [PT]

  • #5
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,172
    Thanks
    19
    Thanked 65 Times in 64 Posts
    Looks like I was being too clever it was looking for a space not %20


  •  

    Posting Permissions

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