Forum Moderators: phranque
would redirect to:
www.example.com/gallery/people/template.php?page=index
The rewrite rule I thought would work, but doesn't, is shown below:
RewriteRule ^portfolio/people$ gallery/people/template.php?page=index [L]
The .htaccess file is located in the root directory (www.example.com/)
If I change the rule to a redirect with [R] like this:
RewriteRule ^portfolio/people$ gallery/people/template.php?page=index [R]
it successfully redirects the page and loads from www.example.com/portfolio/people as it should, but of course displaying what I was trying to rewrite in the first place.
Any help would be most appriated!
If this is just a one page redirect then you could use a RedirectPermanent instead:
RedirectPermanent /portfolio/people [your-site-name.com...]
Or are you redirecting a lot of pages such as /portfolio/people/dave to /gallery/people/template.php?page=dave as well?
Andy
Strangely enough, if I redirect www.example.com/portfolio/people to:
www.example.com/gallery/people/template.php?page=test
Using the same rewrite rule that wasn't working with page=index using page=test:
RewriteRule ^portfolio/people$ gallery/people/template.php?page=test [L]
It is rewritten correctly.
I guess the problem lies in the nature of index file? It seems as though the relative paths are getting messed up when I try to use the rewrite rule with the index file.
Is there something different with respect to current working directory path when using mod_rewrite vs when entering in the actual URL?
i.e. if I enter:
www.example.com/portfolio/people and have the rewrite rule:
RewriteRule ^portfolio/people$ gallery/people/template.php?page=index [L]
in my .htaccess file in the root directory, do I end up with a different working directory than when I enter:
www.example.com/gallery/people/template.php?page=index
?
It seems as though this is where the root of my problem lies as the index.htm file has some relative links within it which aren't translated as I would expect.
Any suggestions?
Thanks,
Ranken
The usual solution is to use canonical URLs or to use server-root-relative URLs for images and other included objects such as stylesheets and external JS files, e.g. <img scr="http://example.com/images/my_logo.gif"> or <img src="/images/my_logo.gif">
Jim