• 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
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Try putting this above your rule.

 

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Link to comment
Share on other sites

  • 0

 

Try putting this above your rule.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

 

It worked!

 

Do you mind telling me what is happening there

Overall i am confused how Rewritecond works

Link to comment
Share on other sites

  • 0

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.

Link to comment
Share on other sites

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

    • No registered users viewing this page.