I am having a problem with my RewriteRule for the querystring portion. What I am able to debug is that the rule is being triggered at least because the page tags.php is being rendered but without the URL parameters. This .htaccess file with the rules is within the root folder for my sub-domain and has the following content:# Enable Rewriting  RewriteEngine on  # Rewrite rule for tagsRewriteRule ^tags/(\w+)/(\d+)/?$ tags.php/?tag_name=$1&tag_id=$2 [L]RewriteRule ^tags/(\w+)/?$ tags.php?tag_name=$1    [L]RewriteRule ^tags/?$ tags.php?tag_name= [L]A similar .htaccess file exists for a directory within my sub domain which is working as expected with the necessary URL parameters also being available. The .htaccess file within the directory reads as follows:# Rewrite rule for tagsRewriteRule ^tags/(\w+)/(\d+)/?$ restAPI.php?type=tags&tag_name=$1&tag_id=$2     RewriteRule ^tags/(\w+)/?$ restAPI.php?type=tags&tag_name=$1    RewriteRule ^tags/?$ restAPI.php?type=tags&tag_name=Can anyone see a problem with my RewriteRules? I am also facing an Internal Server Error sometimes which I am second guessing is due to the same problem.I have Apache version 2.2.23 on my shared hosting.UpdateI have following folder structure /sub-domain root |-- .htaccess |-- tags.php |-- article.php |-- index.php |-- folders for Images and JavaScript As suggested by schwarzbrot I also tried changing the rewrite rule associated with 'tags.php' but to my surprise linking it to files which didn't even exist didn't give me any error.
mod_rewrite works within directory not on root
htaccess;mod rewrite;apache2
Various causes are possible here. It would be helpful to know more about your setup (folder layout, virtual host configuration and especially any other contents of your .htaccess files). Some things that come to my mind:As Eric Brandel points out, mod_rewrite will apply all rules present in your .htaccess file (or server config) one by one unless [L] is used to stop processing. The rewritten URL could thus become changed again by subsequent RewriteRules (are there any?) in your .htaccess file before the page is finally being rendered. If this is the case, using [L] at the end of all three lines should be enough to solve your problem. In situations where folders of different subdomains are placed inside of each other, you might need to tell mod_rewrite explicity that the current path is on root level, or the rules will not trigger:RewriteBase /If this doesn't help I would recommend to check if mod_rewrite triggers at all, e.g. by using a very simple redirect rule like this one:RewriteRule .* /?hello [R,L]Reason: It might even be possible that the rendering of tags.php is not due to mod_rewrite, but to apache automatically adding the extension .php when /tags is called (see here). You might need to use RewriteEngine On to turn mod_rewrite on, since has to be activated individually for each virtual host. Maybe it is not yet active on your subdomain.If you are not sure which rule is being triggered currently, you could try to find out by e.g. turning rules temporarily into a redirect instead of a rewrite:RewriteEngine OnRewriteBase /RewriteRule ^tags/(\w+)/(\d+)/?$  tags.php?tag_name=$1&tag_id=$2 [R,L]RewriteRule ^tags/(\w+)/?$ tags.php?tag_name=$1 [R,L]RewriteRule ^tags/?$ tags.php?tag_name= [R,L]Edit: Maybe this prevents the server from triggering the rule if the script goes by the the same name, so you can keep tags as the folder name:Options -Multiviews(see https://stackoverflow.com/questions/444592/mod-rewrite-rules-and-content-negotiation for another example)