This URL works perfectly in that the URL does not change in the address bar:
Recently I have been working on a facelift for my website, so I put all the needed files into a directory called newVersion. Now when I go to this URL:
Somehow the URL is no longer pretty and reverts back to the ugly format:
Here are the relevant lines in my .htaccess file:
RewriteRule ^essential-oils/([0-9]+)$ http://www.oil-testimonials.com/newVersion/essential-oils.php?tID=$1 [L]
RewriteRule ^essential-oils/([0-9]+)/$ http://www.oil-testimonials.com/newVersion/essential-oils.php?tID=$1 [L]
RewriteRule ^essential-oils/([0-9]+)/([a-zA-Z0-9\+]+)$ http://www.oil-testimonials.com/newVersion/essential-oils.php?tID=$1&q=$2 [L]
Does anyone know whey I have to use the full path otherwise the RewriteRule does not work? Does it have anything to do with the fact that I'm running this .htaccess file from within a subdirectory instead of from the root?
I don't remember exactly but make sure you have options MultiViews or options +FollowSymLinks on in .htaccess, try both (seperatley) and see which one works.
I'm not sure of why it isn't working (Apache isn't my forté), but one thing to point out ... I hope this is just a development phase, and not a long-term thing. Having "newversion/" as part of a public URL is just awful. It looks so amateurish, adds a completely unnecessary layer of complexity to the URL (and an additional point of failure for people typing it in), hurts your SEO and looks completely ridiculous when you next revamp the site.
In other words, the basic format of the URL oil-testimonials.com/essential-oils/7484/ should always point to the correct version of the page!
PS - where you're just demonstrating a URL, please don't allow it to become hyperlinked – either leave off the http://www. at the start, or wrap it in [noparse]...[/noparse] tags.
Stevie, not to worry, newVersion is just a temporary thing where I do all my testing. Once all is complete I will replace the code at the root with the code that is in /newVersion
You forced the display of the redirection with the absolute (external) redirection, i.e., http://yadda-yadda. The R=301 (permanent redirection) flag will do the same thing, too, so don't use that if you need to hide your URIs.
When I take your advice and get rid of the full URL, my page only partially loads. Do you have any idea why? Here is what I have in my .htacess file:
When someone is trying to view a testimonial with this format:
RewriteRule ^essential-oils/([0-9]+)/([a-zA-Z0-9\-]+)$ essential-oils.php?tID=$1 [L]
The only reason I can think of is a problem with the PHP script. The only other possible reason is a default output which might happen if tID is not the correct key.
Do you reference any absolute paths in your PHP that don't match the rewrited URL?
This topic is now closed. New replies are no longer allowed.