SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Quick Question

  1. #1
    SitePoint Enthusiast magnam's Avatar
    Join Date
    Jun 2006
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Quick Question

    I accidentally overwrote my htaccess file.

    My urls are no longer working.

    My normal urls look like the following:
    http://www.site.com/video.php?id=23057

    They used to look like:
    http://www.site.com/4/category/23057...itle-goes-here

    How can I fix the htaccess file so that the above link goes to:
    http://www.site.com/video.php?id=23057

    I've tried several things that do not work. Thx.

  2. #2
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this.. Not sure if this is the best way and I'm not great at regex but I think it will work. Only thing I'm not sure about is escaping the - character in the regex. If the first one doesn't work try the second.

    Code:
    <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
      
      RewriteRule ^/?([0-9]+)/([0-9a-zA-Z_-]+)/([0-9]+)/([0-9a-zA-Z_-]+)/?$ /video.php?id=$3
    
    </IfModule>
    Code:
    <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
      
      RewriteRule ^/?([0-9]+)/([0-9a-zA-Z_/-]+)/([0-9]+)/([0-9a-zA-Z_/-]+)/?$ /video.php?id=$3
    
    </IfModule>

  3. #3
    SitePoint Enthusiast magnam's Avatar
    Join Date
    Jun 2006
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The first example worked. Thank you thank you thank you thank you thank you.


Bookmarks

Posting Permissions

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