Can you create front-end for .HTACCESS?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Can you create front-end for .HTACCESS?

Post by simonmlewis »

Hi all.

I need to create a way of applying shorturls to pages. I've seen it on some web sites where www.domain.com/thispage is actually going to some long URL.

I either need to do it using HTACCESS, or is there a way to create a FOLDER and a HTML with dynamic numbers in the code, on the fly?

So for example, you have www.somedomain.co.uk, and someone creates an account.
I want that account to create a /joseph on the fly, either thru htaccess, or a physical folder on the server. With either a meta refresh redirect, or a

Code: Select all

<script>
window.location.replace('https://www.domain.co.uk/index.php?page=myprofile&u=y')
</script>
Type code placed into the file.

I've really no idea how to do either, or what is the best method to do it and manage.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: Can you create front-end for .HTACCESS?

Post by twinedev »

At work now, so can't dive into explanation too much, but what you are looking for is the use of mod_rewrite (which most likely can be set up via .htaccess, most hosting does allow this).

I always end up looking up examples when I need to do it, else I'd post exact code here for you. You can have it either be simple:

http://domain.com/jospeh redirects to a something like http://domain.com/index.php?page=myprof ... ame=joseph

(the script being called, to be useful, needs to have what you entered passed to it.

-Greg
Post Reply