mod_rewrite works within directory not on root
Posted
by
Anvesh Saxena
on Pro Webmasters
See other posts from Pro Webmasters
or by Anvesh Saxena
Published on 2012-12-15T07:47:01Z
Indexed on
2012/12/15
11:23 UTC
Read the original article
Hit count: 302
I am having problem in my RewriteRule for the tags portion. What I am able to debug is that the rule is been triggered at least because the page "tags.php" is been rendered but without the URL parameters. This .htaccess file with the rules is within root for my sub-domain and has following content for tags postion.
# Rewrite rule for tags
RewriteRule ^tags/(\w+)/(\d+)/?$ tags.php?tag_name=$1&tag_id=$2
RewriteRule ^tags/(\w+)/?$ tags.php?tag_name=$1
RewriteRule ^tags/?$ tags.php?tag_name=
Another problem that I ain't able to debug is that the similar .htaccess file exists for a directory within my sub domain and is working as expected with the necessary URL parameters also been 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=
Could anyone point me the problem that I might be having in my Rewrite rules, I am also facing Internal server error sometimes which I am second guessing is due to the linked problem.
Note:- I have Apache version 2.2.23 on my shared hosting.
© Pro Webmasters or respective owner