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)
-   -   Anybody here know regex and redirect match? (https://gfy.com/showthread.php?t=1298253)

Mr Pheer 04-26-2018 07:31 PM

Anybody here know regex and redirect match?
 
Holy shit it's not a political thread...

Pretend we are working with something like this:
domain.com/montana/milfs-in-bozeman.php
domain.com/montana/bozeman-is-boring.php
domain.com/montana/fuck-bozeman-it-sucks-here.php
domain.com/montana/whatever-bozeman-random-shit.php

And you want to redirect anything in the /montana/ folder that mentions bozeman to a new folder

domain.com/montana/bozeman/index.php

I dont need to match the filename in the new folder, I have plans for something different... just need to match the city and send it to the correct folder. Right now all the cities are just dumped in one folder... thousands of pages actually.

Somebody have a htaccess code for this?

money biz 04-26-2018 09:33 PM

Not sure what you mean but I generate those types of pages and redirect using a cloaker

Mr Pheer 04-26-2018 10:15 PM

Quote:

Originally Posted by money biz (Post 22260162)
Not sure what you mean but I generate those types of pages and redirect using a cloaker

Generating pages is easy and only takes seconds. Doing mass 301 redirects for pages that already have listings while maintaining SEO the correct way is more challenging.

money biz 04-26-2018 11:38 PM

Only way I know is to import your pages into wordpress and use a cloaker plugin. Then redirect off keywords/searches anywhere you want.

Mr Pheer 04-26-2018 11:50 PM

Quote:

Originally Posted by money biz (Post 22260192)
Only way I know is to import your pages into wordpress and use a cloaker plugin. Then redirect off keywords/searches anywhere you want.

Wordpress?

OMG no...

WiredGuy 04-27-2018 12:14 AM

It's been a while since doing htaccess redirects, but you should be able to do a conditional match with regexp to match #domain.com/(.*?)/(.*?)bozeman(.*?)#

WG

Mr Pheer 04-27-2018 12:31 AM

Quote:

Originally Posted by WiredGuy (Post 22260199)
It's been a while since doing htaccess redirects, but you should be able to do a conditional match with regexp to match #domain.com/(.*?)/(.*?)bozeman(.*?)#

WG

Could you please type the whole thing?

I can figure it out but it's like missing three digits of a phone number :)

Bladewire 04-27-2018 12:45 AM

You sneaky sneaky little mynx you

EddyTheDog 04-27-2018 01:49 AM

Just the word 'regex' makes my head hurt - The guy that invented it must still laugh when he sees geeks tearing what little hair they have left out...

blackmonsters 04-27-2018 07:53 AM

[The correct answer has been blocked because Blackmonsters is on your shit list.]

Cyber Fucker 04-27-2018 09:10 AM

There are many ways to achive that, one would be to place local .htaccess to /montana/ directory with the following lines:

Code:

<IfModule mod_rewrite.c>
RewriteEngine  on
RewriteCond %{REQUEST_URI} ^.*(bozeman).*$
RewriteRule ^ /montana/bozeman/index.php [L,R=302,NE]
</IfModule>


Mr Pheer 04-27-2018 03:35 PM

Quote:

Originally Posted by blackmonsters (Post 22260324)
[The correct answer has been blocked because Blackmonsters is on your shit list.]

Since when?

Mr Pheer 04-27-2018 03:57 PM

Quote:

Originally Posted by Cyber Fucker (Post 22260352)
There are many ways to achive that, one would be to place local .htaccess to /montana/ directory with the following lines:

Code:

<IfModule mod_rewrite.c>
RewriteEngine  on
RewriteCond %{REQUEST_URI} ^.*(bozeman).*$
RewriteRule ^ /montana/bozeman/index.php [L,R=302,NE]
</IfModule>


This almost works but it gives me some weird redirect loop

Mr Pheer 04-27-2018 05:03 PM

I'm just deleting it and rebuilding it. Spent too much time on it already, and google will respider the whole thing in a couple of days. No big deal.

Cyber Fucker 04-27-2018 05:06 PM

Quote:

Originally Posted by Mr Pheer (Post 22260522)
This almost works but it gives me some weird redirect loop

Yup, could be, cause the url redirected to also contains the "bozeman" keyword.

So, you can add some condition before to ignore the url you are redirecting to for example:


Code:

<IfModule mod_rewrite.c>
RewriteEngine  on
RewriteCond %{REQUEST_URI} !^.*(\/montana\/bozeman\/index.php)$
RewriteCond %{REQUEST_URI} ^.*(bozeman).*$
RewriteRule ^ /montana/bozeman/index.php [L,R=302,NE]
</IfModule>


Mr Pheer 04-27-2018 08:25 PM

Quote:

Originally Posted by Cyber Fucker (Post 22260537)
Yup, could be, cause the url redirected to also contains the "bozeman" keyword.

So, you can add some condition before to ignore the url you are redirecting to for example:


Code:

<IfModule mod_rewrite.c>
RewriteEngine  on
RewriteCond %{REQUEST_URI} !^.*(\/montana\/bozeman\/index.php)$
RewriteCond %{REQUEST_URI} ^.*(bozeman).*$
RewriteRule ^ /montana/bozeman/index.php [L,R=302,NE]
</IfModule>


Thanks, I will try this out and let you know if it works. Luckily I got distracted earlier and havent deleted it yet :)

Mr Pheer 04-27-2018 09:19 PM

That worked great :)

Thanks, Cyber Fucker! :thumbsup


All times are GMT -7. The time now is 12:26 PM.

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