busboy — 2012-07-19T18:14:23-04:00 — #1
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?
maxdream01 — 2012-07-19T18:33:55-04:00 — #2
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.
stevie_d — 2012-07-19T18:40:02-04:00 — #3
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.
busboy — 2012-07-20T01:03:29-04:00 — #4
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
dklynn — 2012-07-20T06:29:23-04:00 — #5
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.
busboy — 2012-07-24T18:55:37-04:00 — #6
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]
dklynn — 2012-07-25T03:44:10-04:00 — #7
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.
serverstorm — 2012-07-28T12:01:17-04:00 — #8
Do you reference any absolute paths in your PHP that don't match the rewrited URL?