We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Htaccess rewrite rule help

Travis Hydzik
on
Medium Priority
276 Views
Last Modified: 2012-08-13
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
Comment
Watch Question

Add this to your webroot folder .htaccess

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

Open in new window


hope this help
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Travis HydzikVarious
CERTIFIED EXPERT

Author

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

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

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

Open in new window

Travis HydzikVarious
CERTIFIED EXPERT

Author

Commented:
still not working.
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Browser sends URL-encoded version of special characters to server but rewrite decisions are made after the URL is decoded to the original form.
Travis HydzikVarious
CERTIFIED EXPERT

Author

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
change (.+) to (.*)
Travis HydzikVarious
CERTIFIED EXPERT

Author

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

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.
please check /.htaccess and see what do you have there
Travis HydzikVarious
CERTIFIED EXPERT

Author

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.
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.
Various
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Travis HydzikVarious
CERTIFIED EXPERT

Author

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

awarded points to experts who helped.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.