Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 02-25-2022, 03:15 AM   #1
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana.
Posts: 653
.htaccess question / url rewrite (?)

I know this should be possible but I'm having difficulty figuring out how.

I have a php variable at the top of my page like this:

Quote:
$collection = "blah blah something something";
What I'm trying to do is have it so that my .htaccess file will rewrite the URL of the page it is on to contain the verbiage inside that variable and that will become the url of the page like this:

domain.com/directory/blah-blah-something-something.php

Would anyone happen to know if this actually is doable, the page has a .php extension and secondly, would you happen to have the .htaccess code needed to make this happen?

Thanks for any help you can offer.

Oh and Happy Mardi Gras everyone

__________________
PublisherBucks
Wellness Affiliate Program.
Publisher Bucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-25-2022, 03:59 AM   #2
zijlstravideo
Confirmed User
 
zijlstravideo's Avatar
 
Industry Role:
Join Date: Sep 2013
Location: The Netherlands
Posts: 805
Sure, that's doable.

Your php file, it should look something like this:

$collection = "blah blah something something";
$actual_Link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$post_Link = preg_replace("![^a-z0-9]+!i", "-", strtolower($collection));
$post_Link = rtrim($post_Link, "-");
$rewrite_Link = "http://$_SERVER[HTTP_HOST]/directory/".$post_Link.".php";
if($rewrite_Link !== $actual_Link)
{
header("Location: $rewrite_Link,TRUE,301);
die();
}


And your htaccess something like this:

RewriteRule directory/(.*)\.php$ yourrealfile.php?id=$1 [L]

Not entirely sure about the htaccess part though. It looks a bit off. Anyway, it's untested, but I think it should point you in the right direction.


And make sure you get the value inside $collection from somewhere safe. Might want to check and verify if it's a match in your SQL database or something, before redirecting.
__________________
Contact: email
zijlstravideo is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-25-2022, 12:57 PM   #3
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana.
Posts: 653
Quote:
Originally Posted by zijlstravideo View Post
Sure, that's doable.

Your php file, it should look something like this:

$collection = "blah blah something something";
$actual_Link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$post_Link = preg_replace("![^a-z0-9]+!i", "-", strtolower($collection));
$post_Link = rtrim($post_Link, "-");
$rewrite_Link = "http://$_SERVER[HTTP_HOST]/directory/".$post_Link.".php";
if($rewrite_Link !== $actual_Link)
{
header("Location: $rewrite_Link,TRUE,301);
die();
}


And your htaccess something like this:

RewriteRule directory/(.*)\.php$ yourrealfile.php?id=$1 [L]

Not entirely sure about the htaccess part though. It looks a bit off. Anyway, it's untested, but I think it should point you in the right direction.


And make sure you get the value inside $collection from somewhere safe. Might want to check and verify if it's a match in your SQL database or something, before redirecting.
Awesome, thanks, will have a play with this shortly
__________________
PublisherBucks
Wellness Affiliate Program.
Publisher Bucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-02-2022, 11:07 PM   #4
u-Bob
there's no $$$ in porn
 
u-Bob's Avatar
 
Industry Role:
Join Date: Jul 2005
Location: icq: 195./568.-230 (btw: not getting offline msgs)
Posts: 33,063
.htaccess :
Code:
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .+ %{DOCUMENT_ROOT}/whereveryouwannakeepthis/404.php [L]
404.php:
Code:
<?php

$uri = $_SERVER['REQUEST_URI'];

$path = parse_url($uri, PHP_URL_PATH);

$filename = basename($path);

if($collection = substr($filename, 0, strpos($filename, ".php")) )
{ 
$collection = str_replace("-"," ",$collection);
print $collection;
}
else
{
http_response_code(404);
exit;
}

?>
u-Bob is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks

Tags
page, .htaccess, url, happen, variable, blah, rewrite, gras, thumbsup, doable, .php, mardi, offer, extension, code, happy, figuring, difficulty, question, top, $collection, verbiage, inside, file, something;



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.