![]() |
.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 :thumbsup http://www.publisherbucks.com/mardigras.jpg |
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. |
Quote:
|
.htaccess :
Code:
RewriteEngine On Code:
<?php |
All times are GMT -7. The time now is 12:41 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc