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

Thread: Rewrite Help

  1. #1
    Regular Coder
    Join Date
    Jul 2010
    Location
    Sheffield
    Posts
    822
    Thanks
    93
    Thanked 18 Times in 18 Posts

    Rewrite Help

    A while ago i was kinda getting there with Rewrite, but i've not done it in a while and totally lost it. Basically what im trying to do is if someone types "www.example.co.uk/sub/brochure", it to redirect to "www.example.co.uk/sub/index.php?page=brochure". Im not sure if thats possible or if it would have to be like ".co.uk/sub/page/brochure", but either way i cant get it working. Because the .htaccess is stored in the same folder as the "sub" folder, i tried "RewriteRule ^sub/([a-z]+)$ /sub/index.php?page=$1/ [R]" but that didnt work, and i tried messing about a few other ways but with no look, if anyone can gimmie a hand getting this basic one started im sure i can pick the rest up again.

    Thanks

  • #2
    Regular Coder poyzn's Avatar
    Join Date
    Nov 2010
    Posts
    266
    Thanks
    2
    Thanked 61 Times in 61 Posts
    try this code
    Code:
    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^\/sub\/
    RewriteRule ^sub/([a-z]+)\/?$ /sub/index.php?page=$1 [L]

  • #3
    Regular Coder
    Join Date
    Jul 2010
    Location
    Sheffield
    Posts
    822
    Thanks
    93
    Thanked 18 Times in 18 Posts
    Thanks, ill give that a try later on when i get access to a ftp, what does the REQUEST URI line do?

  • #4
    Regular Coder poyzn's Avatar
    Join Date
    Nov 2010
    Posts
    266
    Thanks
    2
    Thanked 61 Times in 61 Posts
    Quote Originally Posted by tomharto View Post
    Thanks, ill give that a try later on when i get access to a ftp, what does the REQUEST URI line do?
    it reads requested uri and apply next rewrite rule only for the matching
    Last edited by poyzn; 01-18-2011 at 10:19 AM.

  • #5
    Regular Coder
    Join Date
    Jul 2010
    Location
    Sheffield
    Posts
    822
    Thanks
    93
    Thanked 18 Times in 18 Posts
    Oh, ok thanks. Im still VERY new to all of this so i have a lot to learn :P


  •  

    Posting Permissions

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