Forum Moderators: phranque

Message Too Old, No Replies

How do I get rid of a trailing /0 at end of URL?

         

alzika

2:04 am on Feb 25, 2012 (gmt 0)

10+ Year Member



I'm trying to use .htaccess and mod_rewrite to remove a /0 at the end of a URL. I'm not sure why it is adding that, but I have no clue what to do to get it to remove the 0. It can keep the / or remove it, that doesn't matter.

For example:

I want test.com/test/0 to perma redirect to test.com/test

g1smd

2:27 am on Feb 25, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Let's see your code so far.

Also, run Xenu Linksleuth over your site to see if that URL is being generated within any of the on-site links.

alzika

2:31 am on Feb 25, 2012 (gmt 0)

10+ Year Member



Problem is, I don't have any code that I can access at the moment. I'm trying to make it so that anything that comes after say, the /test/ directory is just truncated off.

A flash developer made an error and is sending back weird URLs such as /test/2/0 or /test/[object Object]/0 or just /test/0.

I need to fix his mistake without modifying the flash and just truncate everything after the test/

lucy24

2:37 am on Feb 25, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It can keep the / or remove it, that doesn't matter.

Actually it does matter, assuming those are directories. If you don't keep the / then mod_dir will reappend it for you, resulting in a double redirect. (You can see it in your logs, or through Live Headers or similar. It's a full-fledged 301 Redirect.)

I'm not sure why it is adding that

First step is to figure out what and where "it" is. No use fixing something in htaccess if the error originates on one of your own pages. Or-- nasty thought-- a booboo elsewhere in htaccess.

Problem is, I don't have any code that I can access at the moment. I'm trying to ...

He meant, let's see what your htaccess looks like so far. You have to learn to do it yourself-- even if it means that people over here spend four times as long ripping your code to pieces as it would take to do it for you in the first place :)

Oh yes and... Did you pay the flash developer? If so, you're absolutely entitled to force him to get it right. But that may be a different thread.

alzika

9:00 am on Feb 25, 2012 (gmt 0)

10+ Year Member



I am not the owner of the site. I did not pay the flash developer. I'm trying to fix the horrible code that the original programmer did (imagine PHP config and class files with a filename extension of only... .class!) I had to inform the site owner that since the file wasn't a .php file, that anyone could view the contents of their PHP code if they wished. HUGE security flaw.

Again, all I'm trying to do is clean the site up and fix problems from the original dev. I'm not even sure the .FLA file exists as it is just a SWF. If I can get ahold of the original FLA, I will obviously fix it within his buggy code, but we need a workaround now to get the site functional and remove the dead links.

Sometimes it even returns a URL like /test/2/0/[object Object] so its not only just one "subdirectory" deep. It can be multiples.

I just need a .htaccess mod_rewrite portion that will let me specify the specfic directories (test in this example) and have anyone who tries to visit the above URL be automatically perma redirected to just /test/ instead of /test/2/0/[object Object]

I'm very confused as to why my attempts are not working.

lucy24

9:11 am on Feb 25, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm very confused as to why my attempts are not working.

Well, as g1 said up above, let's see what your attempts look like so far. Can't possibly be any worse than all the other stuff that passes through here in the course of a week :)

Make sure you explain exactly what you mean by "isn't working". It may be obvious to you, but in fact there are many ways* for htaccess not to work.


* 500, give or take.

alzika

9:20 am on Feb 25, 2012 (gmt 0)

10+ Year Member



I think I must have been one of the more idiotic ones, then.

I guess it was a cache issue. I tried it in a different browser and now the .htaccess works fine.

I've spent all night on a damn issue with basically my cache, lol.

g1smd

10:23 am on Feb 25, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Let's see the code anyway.

There will be at least several ways to optimise it.

lucy24

12:32 pm on Feb 25, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I've spent all night on a damn issue with basically my cache, lol.

Do a Forums search for cache + htaccess with the site constrained to /apache and you will find any number of "Been there, done that" posts with surprising names attached to them.

Now stop being coy and lessee what you've got :)