Reputation: 58
I'm having some problems. I searched a lot, tried variations, and still can't get this working.
My aim is simply this:
Redirect: http://site.com/folder1/folder2/page
To: http://site.com/folder1/folder2/Page
Notice that I'm using "Friendly URLs".
Now here are the methods I tried, and the problems I came accross.
1) Redirect 301
Redirect 301 /folder1/folder2/page http://site.com/folder1/folder2/Page
This Redirect works, the problem is, my Get Variables from "page" are appearing at the end of the URL, which is bad for SEO:
http://site.com/folder1/folder2/Page?get=page
2) RewriteRule
RewriteRule of mod_rewrite is supposed to fix the problem of the Get Variables appearing (From what I've read).
The problem is, I'm not getting it to work for my Fancy URL structure.
RewriteRule ^/folder1/folder2/page$ http://site.com/folder1/folder2/Page [R=301,L]
It simply doesn't work. The Redirect isn't carried out, so something must be wrong here. I tried many variations to that code.
Can't you use RewriteRule directly on Friendly URLs?
(Friendly URL meaning I stripped off the .php extension)
Looking forward to some help! Thanks!
Update 1:
Please note that Case Sensitivity is Not the issue here.
Even if my example was: Page1 => Page 2
Instead of: page => Page
The problems still persist.
Update 2:
This is the closest solution I got so far (but still not there yet):
Redirect 301 /folder1/folder2/page http://site.com/folder1/folder2/Page?
I added a "?" at the end.
This will give me the landing URL of: http://site.com/folder1/folder2/Page?
It removes the Get Variables, but still not as SEO friendly as I would like.
Upvotes: 0
Views: 484
Reputation: 150
I can't say I'm totally clear on the question here: are you trying to get the capitalization rule to match or to lose any query string? Both?
If it's capitalization, I believe the rule works (with the corrected typo Rajesh and hakre call out) removed. It it's the desire to strip the query string try adding a trailing ? to the second half of your rule. It'd look like:
RewriteRule ^folder1/folder2/page$ http://site.com/folder1/folder2/Page? [R=301,L]
Upvotes: 0
Reputation:
In the second case, if you are adding the rewrite rule in your htaccess file, the leading slash shouldn't be matched against.
Try:
RewriteRule ^folder1/folder2/page$ http://site.com/folder1/folder2/Page [R=301,L]
why you ask? Good question!
Upvotes: 0