![]() |
Need help of Mod Rewrite
Hi, i am trying to rewrite my url.
-the first rule will rewrite images/C.jpg to images/C.php. But the second line of my mod rewrite would redirect all files except for(js, gif, jpg, png and css) to index.php. The problem is, after my images/C.jpg is rewrite, the request will treat is as requesting a php file, and would be redirected to the index.php, so having a [L](Lock) would be useless too?? how do i solve this? Thanks I currently have this: Code:
RewriteRule images/C.jpg images/C.php [NC,L] |
i use something along the lines of the following...
Code:
RewriteEngine on |
@jlodell: he wants to deny access to an existing file, so your rules will have no effect there.
one quick fix would be to add images/C.php into the second's rule exception list, which should be a RewriteCond rule rather than a RewriteRule: Code:
# your rules go hereps2: ALWAYS escape characters other than letters and numbers in regex rules. just to be on the safe side. |
@xenon: you are right, but i'm just throwing out another approach on how to go about filtering with mod_rewrite. I honestly don't know what is going on with the C.jpg -> C.php but i don't see why that would imply that it is for denying access to a file?
Clarity... What I really meant was, "Here is a basic start at a .htaccess file that shows a different approach to redirecting traffic thru a front controller." Code:
RewriteEngine onCode:
RewriteEngine on2 cents: I don't see the reasoning for the jpg->php change? I guess i am missing it or something. i realize that this will keep the image from getting served but wouldn't it be easier to just place it somewhere else instead of checking every request? Using this method it will NEVER get served to any request. It isn't like it is being filtered to only be served to a certain IP or what-not. It just seems a bit pointless, thats all. good luck, justin |
| All times are GMT. The time now is 06:55 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0