Jump to content

How Do You Do Something Like This?


ColdEdge
 Share

Recommended Posts

Ok, so I seen some sites that when user either posts a thread or in my case submits and image ^^ (trying to make a gallery site) there image is added and a page is generated. However I don't want to use picture.php?iid=hjK74k3lk to point to the image but instead I want to make a link look like this depending on what title the user has inputed in the submission form.So say when users adds his/her wallpaper to the gallery the link would look like this "wallpapers/view/186748/bakemonogatari" instead of picture.php?iid=hjK74k3lkAnd I am aware that using picture.php that all the data is called via MySQL but I am lost when trying to understand how sites have this kind of URL's "wallpapers/view/186748/bakemonogatari" I am sure that this is a directory which is created but how can I do that? As well how is the data processed? I will be very thank full if any one can help me out with this. And point me to required functions on php.net if you can explain the process that will also be helpful thank you.

Link to comment
Share on other sites

It's not a physical directory - they use URL rewriting. If you are on an Apache host, you can use mod_rewrite to do that.

Link to comment
Share on other sites

@SynookI have taken a look in mod_rewrite a while back thinking it should be the main piece of this puzzle. But the problem is that I don't understand the structure. Theres a main directory called "wallpapers/" and then there is a 6 digit number "167437/" and after that we have the title "taiga/" how would this be shown in mod_rewrite?

Link to comment
Share on other sites

Well, the number could be the actual ID, so it might look something like this:

RewriteRule ^wallpapers/view/([0-9]+)/(.+)$ picture.php?iid=$1&title=$2

Of course if your IDs were not just numbers, then you would allow non-numeric characters in the first reference.

Edited by Synook
Link to comment
Share on other sites

Hmm. I gave it a try and no good it dose not rename the url it still works under picture?idd=# here is the code

Options -MultiViews +FollowSymlinks -Indexes<IfModule mod_security.c>	SecFilterEngine Off	SecFilterScanPOST Off</IfModule><IfModule mod_rewrite.c>	RewriteEngine on	RewriteRule ^wallpapers/view/([0-9]+)/(.+)$ picture.php?iid=$1&title=$2		<IfModule mod_env.c>		SetEnv SEO_SUPPORT 1	</IfModule></IfModule><IfModule mod_deflate.c>	AddOutputFilterByType DEFLATE application/x-javascript text/css text/html text/xml</IfModule>

Link to comment
Share on other sites

Do you have mod_rewrite on your system? Also, depending on your file structure you may need to use RewriteBase, e.g.

RewriteBase /directory_with_picture_php/

Note: I didn't test the rule.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...