Richard Grant Posted October 8, 2014 Share Posted October 8, 2014 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 More sharing options...
0 +virtorio MVC Posted October 8, 2014 MVC Share Posted October 8, 2014 Try putting this above your rule. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d Link to comment Share on other sites More sharing options...
0 Richard Grant Posted October 8, 2014 Author Share Posted October 8, 2014 Reserved. Link to comment Share on other sites More sharing options...
0 Richard Grant Posted October 8, 2014 Author Share Posted October 8, 2014 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 More sharing options...
0 +virtorio MVC Posted October 8, 2014 MVC Share Posted October 8, 2014 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 More sharing options...
Question
Richard Grant
I have this: (works)
I want this: (doesnt work)
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