Remove file name “specification.php?url=” from url - php

This is a link on index.php page
<?= $mbbelow['brand_name']; ?><?= $mbbelow['title']; ?>
from this link I come on page specification.php
then this url come http://www.themobilesapp.com/specification.php?url=Sony-Xperia-Z5-specifications-5246.php
in the base of url I find all data of page.
This url is not proper according to me.
Here I want to remove specification.php?url= from this above url.
Please tell me in proper and full explain way that how to remove and make new url like this
http://www.themobilesapp.com/Sony-Xperia-Z5-specifications-5246.php
I only need .htaccess or I also need to work using php code to remove this.
I will provide you all details you need here for to remove this.

Please try this in .htaccess file:
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ specification.php?url=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ specification.php?url=$1

Related

Redirect some pages to url and some to another in the same domain

My question title may not be appropriate but you i can try to explain the problem i am, running through here in the description :
What i want is that one page of the site should be redirected to a particular url and the rest to another one.
i.e.
www.mysite.com/industries/accounting.php should redirect to www.mysite.com/new-industries/accounting
where as
www.mysite.com/* should point to www.mysite.com/newsite
I hope i make sense here. issue is that whenever i try to put in a rule it gets looped for the specific page. any help is appreciated.
Regards.
You can use this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteRule ^industries/accounting\.php$ /new-industries/accounting [L,NC,R=302]
RewriteRule ^((?!newsite/).*)$ /newsite/$1 [L,NC,NE,R=302]

Using a variable in the address bar to display an image?

I have a little problem I can't seem to get my head around. What I'm trying to do is that when someone "http://domain.com/directory/ImgVariableHere" it will display the image on a php page. I know I'm probably going about this the complete wrong way and that's why I've come here. I'm a newbie to PHP so please forgive me. Here's the code I have.
<?php
$img="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
echo "<img src=\"$img.png\">\n";
?>
Here's the code it echos.
<img src="http://domain.com/directory/.png">
I'm probably explaining this really badly, ask any questions of you need to. Thanks. If you have a completely different and better way of doing it then please do tell.
EDIT: What I'm trying to do is kind of like Gyazo. They show their images on a webpage, I'm trying to do that but by using variables in PHP and I just can't wrap my head around it.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [PT,L]
</IfModule>
Put this in .htaccess in the root of your document, and it should route all requests to index.php, then you just put the script above in index.php, and it should work.
It looks like you want to have a RewriteURL with a variable in it.
So when you want this we can create a .htaccess which will reserve a spot for your variable. Example is like this:
RewriteEngine on
RewriteBase / #Maybe your in a subfolder? Change this to /yoursubfolder/secondsub/...
#Redirect all urls that begin with /image/ to image_shower.php?image=<image value>
RewriteRule image/(.*) image_shower.php?image=$1
This rewrite all the urls that begin with /image/ to the image_shower.php without showing the image_shower.php URL. It also sends the information in a GET variable. Which can be easily retrieve in PHP. Like this:
<?php
$img="http://".$_SERVER['HTTP_HOST']. '/' . $_GET['image'];
echo "<img src=\"$img.png\">\n";
?>
Hope this will help you go further!

Generating random URL for each Thank You page

I'm fiddeling around with a problem and cant find a solution. What is basically needed is that I have a site where download button inserts a random code in the end of the URL, example
Thank you
But currently the url will look like xx.mydomain.com/thanks.php?uq=2js98 or etc, what I would like to do, is that the url would look xx.mydomain.com/thanks2js98.php or just xx.mydomain.com/thanks2js98
I have tried all the info I can find, but I think I'm not at home with all the code :(
Step 1:
Modify your PHP code to this:
Thank you
Step 2:
Put this code your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteRule ^(thanks)[0-9]+(\.php)$ /$1$2 [L,NC]

How to make dynamic pages seo friendly url using htaccess

In my php page i have given link as href="test.php?category="xyz".
In url I want this page link to appear as "test/xyz".
In my .htaccess file i have added
RewriteRule ^test/([a-zA-Z]+) test.php?category=$
but this does'nt work for me.
All the other links in test.php gets test appended to their links.
eg. if there was example.php its appears as test/example.php
Help is appreciated.
Thanks in advance
Maybe this code can help you
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^test/([a-zA-Z]+)$ test.php?category=$1
</IfModule>
Try to access these urls : test.php?category=abc and test/abc. If two pages show the same content this code successful.
To learn more, please read the reference here
This sounds more like you forgot the use full relative paths in your links. Instead of using:
example
You should use:
example
Else when you are on page /test/abcd, going to example.php means /test/example.php

PHP - Remove the Specific Segment from URL

I have showing the ad banners in .../openx/banner.php
Each Banner I had set the Banner Link.
After clicking the Banners the Page is redirected with the following URL.
.../openx/www/delivery/ck.php?oaparams=2__bannerid=1__zoneid=1__cb=5b97a864fe__oadest=http%3A%2F%2Fwww.google.com
Here is the root URL : openx/
I want to remove the last segment that is oadest=http%3A%2F%2Fwww.google.com when the page is loaded.
Please anyone help me...
Thanks...
Assuming this string is always at the end of your url, try putting this in the appropriate place on your .htaccess file:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*)oadset=(.*)$
RewriteRule ^/?ck\.php$ /ck.php?%1 [L]

Categories