How to rewrite URLs in PHP using .htaccess, I have tried it but it's not working? - url-rewriting

can anyone please help me to rewrite url in php...
http://localhost:81/cabnotels/Domestic-tours/tour.php?Delhi&india%27s-golden-triangle-tour&type=tour&id=19
This is the current URL and I want to rewrite as..
http://localhost:81/cabnotels/Domestic-tours/tour/Delhi/india's-golden-triangle-tour/tour/19
Please help..
Thank you in advance.

You can not use comma in your url like you have in (india's) and you can rewrite your url using the htaccess like:
RewriteRule ^cabnotels/domestic-tours/tours/([^/]*)/([^/]*)/tour/([^/]*)$ tour.php?$1&$2&$3&$4 [QSA,L,NC]
OR Simply if you have only one URL:
RewriteRule ^cabnotels/Domestic-tours/tour/Delhi/indias-golden-triangle-tour/tour/19$ cabnotels/Domestic-tours/tour.php?Delhi&india%27s-golden-triangle-tour&type=tour&id=19

Related

How to setup URL redirect in Cyberpanel (Lightshot)

I am trying to rewrite URLS in my website but unable to do so.
I am using Lightspeed in Cyberpanel. The .htaccess code I used is:
RewriteRule ^([^/d]+)/?$ index.php?id=$1 [QSA]
What my url looks right now: mysite.tld/index.php?a=2322
What I want to look it like: mysite.tld/2322
Thanks in advance!

.htaccess rewrite image urls

I'm trying to figure out how to redirect all image urls like this:
https://example.com/images/FILE.PNG
to this:
https://example.com/old-site/images/FILE.PNG
Is there an easy way to do this with .htaccess? I've looked around, but couldn't find a post anywhere with a similar scenario of adding a sub directory and don't understand htaccess rules well enough to write it myself.
Any and All help is appreciated!
Using URL Rewrite in .htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^/?images/(.*)$ /old-site/images/$1 [R=301,L]
You can use this one-liner rule in your root .htaccess:
RedirectMatch 301 ^(/images/.+)$ /old-site/$1

Single page mod rewriting for SEO

I have a page as follows.
www.mysite.com/about.php
I want this to be set in the htaccess file so that it looks like below.
www.mysite.com/my-keyword-here
Please help me.
Thanks in advance.
Sam
Add this to the htaccess file in your document root:
RewriteEngine On
RewriteRule ^/?my-keyword-here$ /about.php [L]
So now if you enter http://www.mysite.com/my-keyword-here in your browser's URL address bar, you will be returned the content of /about.php.

mod rewrite add url param

I'm working on an integration with Yiiframework and Joomla. I have it working for the most part, but want to make it a little cleaner. The URL that is called in Joomla needs to get some URL Parameters appended to the URL. I have setup the .htaccess to rewrite the URL, but it's not working and I can't figure out why. Please help.
What the URL current is:
/index.php?r=site/index
What I want it to append is "option=com_jumi&fileid=3" so it looks like this
/index.php?r=site/index&option=com_jumi&fileid=3
Here is what I have for the rewrite
RewriteCond %{QUERY_STRING} ^r=(.*)$ [NC]
RewriteRule ^/index.php$ /index.php?r=%1&option=com_jumi&fileid=3 [NC,L,R=301]
Looking for some guidance, thanks

url rewrite in php using web.config

i want to rewrite this url "demo/demo/index.php" to "demo/demo/send.html" in php using web.config file.
I did this url rewrite by using htaccess file
Please somebody help me....
would something like this work?
RewriteEngine on
RewriteRule ^demo/([a-zA-Z0-9_-]+)/([0-9]+)\.html$ index.php?id=2
There really isn't much to go by from your question.

Resources