• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

Htaccess rewrite rule help

Experts,

Please tell me how I can create the following rule;

Redirect
http://mydomain.com/something/somethingelse/otherfile.extension%123abc

To
http://mydomain.com/something/somethingelse/otherfile.extension

something, somethingelse and othefile and extension and all variants can be anything,
%123abc is a constant

thanks
0
thydzik
Asked:
thydzik
  • 7
  • 5
  • 4
3 Solutions
 
thetmanvnCommented:
Add this to your webroot folder .htaccess

RewriteEngine on
RewriteRule (.+)%123abc $1 [L]

Open in new window


hope this help
0
 
thetmanvnCommented:
RewriteEngine on
RewriteRule ^(.+)%123abc$ $1 [L]

Open in new window


Sorry, I forgot 2 characters.
0
 
thydzikAuthor Commented:
this is not quite working as planned;

example to test
http://thydzik.com/tag/php/%26quot

what i have in the htaccess
 
RewriteRule ^(.+)%26quot$ $1 [L]

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
thetmanvnCommented:
Try this sir: (Just add \ character before the '%' character to prevent escaping rule.

RewriteEngine on
RewriteRule ^(.+)\%26quot$ $1 [L]

Open in new window

0
 
thydzikAuthor Commented:
still not working.
0
 
aliganjeiCommented:
%26 is a scape character for &
try this:
RewriteRule ^(.*)&qout$ $1 [L]
0
 
aliganjeiCommented:
Browser sends URL-encoded version of special characters to server but rewrite decisions are made after the URL is decoded to the original form.
0
 
thydzikAuthor Commented:
thanks,

I am doing some more testing, it doesn't look like the basic redirect is working;
i have
RewriteRule ^(.+)aaa$ $1

Open in new window


this
http://thydzik.com/tag/php/aaa
doesn't redirect
0
 
aliganjeiCommented:
change (.+) to (.*)
0
 
thydzikAuthor Commented:
that doesn't change anything
this is what I have
 
RewriteRule ^(.*)aaa$ $1

Open in new window



above it I have
 
RewriteEngine On
RewriteBase /

Open in new window

0
 
aliganjeiCommented:
I see you are using wordpress. I makes everything more complicated because you are using Permalinks and wordpress uses it's own rewrite rules.
I think in your case wordpress rules are in action before your own rule and redirecting /tag/php/aaa to /index.php, so causing wordpress error.
0
 
aliganjeiCommented:
please check /.htaccess and see what do you have there
0
 
thydzikAuthor Commented:
shouldn't I be able to add this rule before all the wordpress rules?

it will take precedence, and then the wordpress rules will kick in.
0
 
thetmanvnCommented:
Yes, you can put your other rules before wordpress when you use this kind of "Pretty" permalinks.
Did you read this article?

http://codex.wordpress.org/Using_Permalinks
Try to test replace all URI to /index.php.
0
 
thydzikAuthor Commented:
I got this working with the following;

RewriteRule ^(.*)\&quot$ http://thydzik.com/$1 [R=301,L]

Open in new window

0
 
thydzikAuthor Commented:
accepted my solution as it is the correct solution.

awarded points to experts who helped.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 7
  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now