GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   htaccess q. (https://gfy.com/showthread.php?t=1112955)

v4 media 06-19-2013 03:02 AM

htaccess q.
 
Got a folder with loads of content called /subdirectory/blah/ want to leave the content in there but use htaccess to call it /anotherdirectory/blah/
so if people click a link for domain.com/subdirectory/blah/ they get the content for domain.com/subdirectory/blah/ but the newurl is domain.com/anotherdirectory/blah/



Does that make sense?

htaccess confuses the fuck out of me. Can never work out what can/cant be done.
I know if I moved the content I can do it with a 301, but if the content hasnīt moved, will it still work?

RewriteRule ^subdirectory/(.*)$ /anotherdirectory/$1 [R=301,NC,L]

miXXXture 06-19-2013 03:07 AM

:2 cents: :pimp

v4 media 06-19-2013 03:15 AM

the redirect does the job, it shows the correct url, but the content doesnt show.

I get a 404 on the directory /new/ and Error 310 (net::ERR_TOO_MANY_REDIRECTS): on /new/blah/

The content on the server is still in /old/ I just want the url to show /new/ sort of like a slug rename in wp.

maybe I cant do it in htaccess without moving the content. its a custom wp post type, so a bit tricky.

paffie 06-19-2013 03:35 AM

i did something like this before on one of my blogs... but i cannot seem to find the htaccess file i used back then...

I suppose it's basically (got this from stackoverflow):
//begin code
RewriteCond %{REQUEST_URI} !^v2/
RewriteRule ^(.*)$ v2/$1 [L]
//end code

Basically, you have a condition when to rewrite, in this case: the url cannot end with v2/
In case the uri doesn't end with v2/, everything after the domain will be rewritten to the v2-directory...

in your case, it will be something like
//begin code
RewriteCond %{REQUEST_URI} ^firstdirectory/
RewriteRule ^(.*)$ seconddirectory/$1 [L]
//end code

I'm not an htaccess guru, try it out for yourself, and see if it works ;-)

v4 media 06-19-2013 03:53 AM

nope that doesnīt want to work either. thx for trying though.
I think Iīm going to have to copy over all the posts, then set up a standard 301 just to take care of the existing links.

woj 06-19-2013 04:39 AM

you are probably missing something simple, icq me 33375924 and I'll work it out for a beer or 2...

v4 media 06-19-2013 05:20 AM

Quote:

Originally Posted by woj (Post 19677091)
you are probably missing something simple, icq me 33375924 and I'll work it out for a beer or 2...

I just bulk changed the custom post type, and set up a 301 and that did the job.
Thougth the changing post types was going to be a pain but found a plugin that did it.
thanks for the offer though.

Stephen 06-19-2013 05:44 AM

Quote:

Originally Posted by v4 media (Post 19677119)
I just bulk changed the custom post type ... found a plugin

This problem is likely caused by using WordPress, which has its own internal rewrite tables in addition to the htaccess it uses.

Plugins can add an extra layer of redirects. Put it on a virtual host and you can have even more rewrites and server-crushing loops.

It's the internal rewrites that cause a lot of headaches for those that don't know they're there :2 cents:

v4 media 06-19-2013 05:51 AM

Quote:

Originally Posted by Stephen (Post 19677139)
This problem is likely caused by using WordPress, which has its own internal rewrite tables in addition to the htaccess it uses.

Plugins can add an extra layer of redirects. Put it on a virtual host and you can have even more rewrites and server-crushing loops.

It's the internal rewrites that cause a lot of headaches for those that don't know they're there :2 cents:

I turned the plugin off after it moved everything. It was just to get everything moved over.


All times are GMT -7. The time now is 04:28 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc