Rewrite URL of php page to be png [closed] - php

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I am thinking of making a tool for my own development similar to placehold.it. I would like to have something like this.
<img src="url.com/picture.php?id=51"/>
to be
<img src="url.com/51.png"/>
Any ideas?
Edit: Even though I have used Stack Overflow to answer questions and looks stuff up, this is my first time asking a question. This is a bit crazy. Apparently it isn't detailed enough. I just thought that less is more sometimes and it seemed to make sense.
Anyway... I am simply wondering if you can make a php page behave like a image. I would like to be able to pass data to my php page, do stuff with the variables, then return content in the form of an image. For example:
This
<img scr="url.com/picture.php?color=blue"/>
Could be seen by the browser as
<img scr="url.com/blue.png"/>
My guess is it needs to be done with a rewrite rule. I have done a little work with those in the past for making pretty urls (www.example.com/some/random/url vs example.com/someRandom.php?a=url) but I wasn't sure if changing the type from php to png would work.
Hopefully this will make sense now.

You can do that using .htaccess.Here is the RewriteRule.
RewriteEngine On
RewriteRule ^([0-9]+).png$ /picture.php?id=$1 [L]
Thanks.

Related

Simplest Routing For URL Queries [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I'm stuck trying to figure out the best approach to my problem. I want to pass query params with a / than a ?.
So for example, instead of:
https://example.com/search.php?q=test
It'd be:
https://example.com/search/test/
I'm not using any PHP framework. How can I reach my goal?
You could do this with your .htaccess file.
For that you need to write in your .htaccess:
RewriteEngine on
RewriteRule ^search/([A-Za-z0-9\-]+)/?$ search.php?q=$1
The first line activate your RewriteEngine, so you can write RewriteRules as much you like.
In the second line you define your first RewriteRule:
In the URL it need to be search/([A-Za-z0-9\-]+)/.
That means, you only allow the characters inside the square bracket.
Then you redirect to your wanted script, in this case its search.php with the GET Parameter.
It's also possible to do this with more parameters or much more. For that you should google maybe "htaccess Explanation".
Better try php router and dont waste the time for rewrite !!!
And test nginx server it is awesome.

How to make a dynamic timeline using bootstrap? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm trying to make a dynamic timeline like facebook that can post pictures and descriptions with dates using mysql php for database. I put bootstrap because I like their design, and it's easy to use.
My problem is i don't know where to begin or where do I study it.
Here's an example of what I'm talking about:
Any suggestions?
What a generic question... this seems to me an impossible question to answer but maybe you need just some little advices to begin studying the right languages which you can use to achieve what you want.
First of all please provide an image of what you want to do and more important the fundamental languages that you have to know are HTML (obviously), CSS, Javascript and PHP for some server side script.
Talking specifically about your problem, here is where you can see some open examples with well commented code that allows you to understand everything.
http://www.jqueryrain.com/2015/05/ideabox-jquery-timeline-news-ticker/
http://www.jqueryrain.com/2014/11/vertical-timeline-css3-jquery/

A specific htaccess inquiry [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
After a bit of research I think its better if I ask for help to a specific problem, because I think if I am to learn the skills needed, I'd be taking on another language, and I can't get into the details of htaccess and regular expression at the moment, hopefully someday.
What I have now in URL is (localhost/site/controller/function/$arg1)
What information do I need to place into the htaccess so the controller and function isn't displayed. But the end result is (localhost/site/$arg1).
I think, this doesn't really make sense. As stated in the comments, you can use mod_rewrite to send your shortened URLs to the controller, but controller and function need to be static. So having a separate function doesn't really help, controller should be enough.
One thing you could do is selecting the RewriteRules in your .htaccess depending on the $arg1 using for example RewriteCond. That way you could send different URLs to different controllers. It depends on your URL structure if this is feasible.

htaccess: How can I hide parts of the link? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Is it possible to hide parts of the link using .htaccess rewrite rule?
I'm working on hotlink protection. The playlist is generated with the following link: http://site.com/get.playlist.php?
the full link:
http://site.com/get.playlist.php?playlist=http://site.com/video/34141ce7760f58f0c3eb5e0c758afb69/pl/playlist.txt&hash=34141ce7760f58f0c3eb5e0c758afb69
i would like to display the link without &hash= and http://site.com/get.playlist.php?playlist=
like this:
http://site.com/video/34141ce7760f58f0c3eb5e0c758afb69/pl/playlist.txt
Unfortunately, this is not possible (at least, not in any rational manner) using .htaccess.
There's no way to change the URL that the browser is displaying- however, you could do the opposite- .htaccess does have the power to keep the URL the same, but display a different page on the server.
This would be a bit harder to setup (especially because of the hash parameter), but may be something for you to consider.

Sound played when database is updated [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am working on a leader-board; I need a sound to be played (automatically) when the values on the leader-board are changed through the CMS.
Any ideas, links, suggestions are very welcome.
Using PHP / MySQL
Thank you.
If you want to play the sound without reloading the page, i think you have to use AJAX. Otherwise you have to check, on reload, with PHP if anything changed. After that you should use javascript to play the sound.
Maybe the or html tags can help you out here? Of course you need some wiring (with PHP or Javascript maybe) to do, to get it working on the moment you want it to.
You should use Javascript to play a sound. Because a browser is clientside the server cannot communicate with a browser to alert it when something has changed.
Basically you should set up some recurring checks in your code that verify if something has changed. If some values did change, you can update your webpage and play a sound by making use of Javascript.
A tutorial about how to play sounds can be found here.

Categories