![]() |
![]() |
![]() |
||||
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. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 | |
Confirmed User
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,116
|
.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:
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 ![]() ![]()
__________________
NOTHING TO SEE HERE |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
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. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 | |
Confirmed User
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,116
|
Quote:
![]()
__________________
NOTHING TO SEE HERE |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
there's no $$$ in porn
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] 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; } ?> |
![]() |
![]() ![]() ![]() ![]() ![]() |