Jump to content

Hide part of directory structure in URLs?


JohnnyDoomo

Recommended Posts

Can someone here help me cut out parts of urls, using htaccess?

 

I am looking to cut this type of url:

 

http://krankr.com/clip/videos.php/photo/62921/Game_Videos/Routine-Oculus_Rift_Alpha_Gameplay_Trailer_HD/

down to this

http://krankr.com/62921/Game_Videos/Routine-Oculus_Rift_Alpha_Gameplay_Trailer_HD/

 

and this type of url

 

http://krankr.com/clip/showgallery.php/cat/503/Game_Videos/

down to this

http://krankr.com/Game_Videos/

 

I'm not sure if someone can share a simple rule with me that I can simply copy and paste the words I want removed from urls like /photo/ and /videos.php/ or if a separate rule needs to be created for each and every type of item I want removed from urls.

 

I need it so that if the old url is entered into a browser, it still works too.

 

Can anybody help me accomplish this?

krankr.com/clip/videos.php/photo/62921/Game_Videos/Routine-Oculus_Rift_Alpha_Gameplay_Trailer_HD/

down to this

krankr.com/62921/Game_Videos/Routine-Oculus_Rift_Alpha_Gameplay_Trailer_HD/

Rewrite "/numbers/category/title/" to "/clip/videos.php/photo/the stuff matched".

 

krankr.com/clip/showgallery.php/cat/503/Game_Videos/

down to this

krankr.com/Game_Videos/

That can only happen if the 503 you're rewriting is not necessary. If it is then you have to include it in the URL you want to show.

 

To rewrite "/Game_Videos-503/" (as an example),

Rewrite "/category-numbers/" (so long as it's not a real file or directory or other part of your site) to "/clip/showgallery.php/cat/numbers/category".

 

For that "not a real file or directory" you can use

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
before your RewriteRule. For the "other part of your site" all you have to do is put this RewriteRule (and the Conds) near the bottom of the list of other things being rewritten. (Don't forget to use [L]s for pretty much everything.)

 

 

Give that a shot?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.