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 tags
RewriteRule ^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 tags
RewriteRule ^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.
Update
I 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.
tag_name
available to your server-side script? If using PHP, does$_GET['tag_name']
exist? This is presumably the only code that directs a request totags.php
?tag_name
is not available to my server-side script fortags.php
. And thanks for correcting my question