• 0

htaccess rewrite


Question

I have this: (works)

#RewriteCond %{REQUEST_URI} ([a-zA-Z0-9]+)
RewriteRule ([a-zA-Z0-9]+) folder/file.php [L]

 

I want this: (doesnt work)

#RewriteCond %{REQUEST_URI} ([a-zA-Z0-9]+)
RewriteRule ([a-zA-Z0-9]+) folder/$1.php [L]

I would like $1 to equal the matched expression ([a-zA-Z0-9]+)

 

 

 

Extra information:

http://mysite.com/file.php rewrites the url to http://mysite.com/file

Link to comment
https://www.neowin.net/forum/topic/1232259-htaccess-rewrite/
Share on other sites

4 answers to this question

Recommended Posts

  • 0
  On 08/10/2014 at 00:39, Richard Grant said:

It worked!

 

Do you mind telling me what is happening there

Overall i am confused how Rewritecond works

It stops rewriting as soon as the request URI points to a file or directory name that exists on the server. Without it, the rewritten string will forever get matched and rewritten again, causing an infinite loop.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

  • Recent Achievements

    • First Post
      Gladiattore earned a badge
      First Post
    • Reacting Well
      Gladiattore earned a badge
      Reacting Well
    • Week One Done
      NeoWeen earned a badge
      Week One Done
    • One Month Later
      BA the Curmudgeon earned a badge
      One Month Later
    • First Post
      Doreen768 earned a badge
      First Post
  • Popular Contributors

    1. 1
      +primortal
      634
    2. 2
      ATLien_0
      256
    3. 3
      Xenon
      164
    4. 4
      neufuse
      142
    5. 5
      +FloatingFatMan
      107
  • Tell a friend

    Love Neowin? Tell a friend!