I am using the following code in .htaccess direct editor in ipage server for changing my website's page url from
for example:
http://foodinger.in/viewRestaurant.php?raipur=Barbecue-Country&id=3006
to
http://foodinger.in/viewRestaurant/raipur/Barbecue-Country
but it is not working
RewriteEngine on
RewriteRule viewRestaurant/raipur/(.*)/ viewRestaurant.php?raipur=$1&id=$2
RewriteRule viewRestaurant/raipur/(.*) viewRestaurant.php?raipur=$1&id=$2
Am i doing anything wrong, Please anyone suggest me the right way if i am wrong ?
Thanks in advance
You specify only one group for substitution (.*) that will replace $1 in target url.
Try:
RewriteEngine on
RewriteRule "^/viewRestaurant/raipur/(.*)/(.*)/?" "/viewRestaurant.php?raipur=$1&id=$2"
And query with Id: http://foodinger.in/viewRestaurant/raipur/Barbecue-Country/3006
Related
I'm trying to change my default url with its parameter from
localhost/webiste/posts.php?name=what-is-btc
to
localhost/webiste/posts.php/what-is-btc
I've tired to main htaccess code RewriteRule ^post([A-Za-z0-9-]+)/?$ post?name=$1 [NC]
But it's not working, can anyone please help me find a way to get it to work?
NB. I'm calling my data dynamically from database and I'm using php get to the name.
Thanks in advance.
You're missing the .php in your RewriteRule and also a leading slash.
Try this:
RewriteRule ^post/([A-Za-z0-9-]+?)/?$ /post.php?name=$1 [NC, L]
my input url is
https://example.com/path/typeX?dataY=mydata
want output as
https://example.com/path/myfile.php?reqType=typeX&dataY=mydata
Please help me , I am new to url re-writing, my serrver is apache with php installed, thanks in advance.
I tried this
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^path/([^\.]+)$ path/myfile.php?reqtype=$1&%1
it is giving correct result on https://htaccess.madewithlove.be/ but not working on server, server says the requested url was not found
I tried to re-write on my own but unable to do so, basically, I want to re-write php-based URL with .htaccess but also need to skip few parameters of php URL for example;
Original URL:
http://example.com/details.php?id=62?title=billions-s01e09-webrip-x264-fumettv
Required Format:
http://example.com/billions-s01e09-webrip-x264-fumettv-id62.html
Format Sequence:
MySiteURL/Title-of-Post-PostID.html
Looking for kind response, please guide me how can i make this possible through .htaccess.
waiting for kind response...
Good day
As you already know that you have to change the .htaccess file in your server. You can use regx to achieve your required url. Using the following code can help you.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z0-9-]+)-id([0-9]+).html?$ details.php?id=$2&title=$1 [QSA,L]
worked fine for me. Hope will work for you too.
To rewrite
http://example.com/foobar-id123.html
to
http://example.com/details.php?id=123?title=foobar
You can use the following rule :
RewriteEngine on
RewriteRule ^([^-]+)-id([0-9]+)\.html$ /details.php?id=$2?title=$1 [NC,L]
I am using WAMP and has created a website in a 'http://localhost/snap2/html' folder. I am trying to execute following Rewrite rule but this is not working for me.
Server is giving me an error below:
The requested URL /snap2/html/browsed.html was not found on this server.
My .htaccess file is located in html folder and its structure is as below:
`RewriteEngine On
RewriteRule ^decision/([0-9]+)$ /snap2/html/decision.php?PanelID=$1`
Website is in a structure like 'www/snap2/html
Infact I am trying to rewrite following url
http://localhost/snap2/html/decision.php?PanelID=20
in to
http://localhost/snap2/html/decision/20
Also Options +FollowSymLinks gives me an error 500 therefore, I have commented it.
Any help would be pretty much appreciated.
Try this:
RewriteEngine On
RewriteRule RewriteRule ^snap2/html/decision/([0-9]+)$ /snap2/html/decision.php?PanelID=$1
But I guess this is not what you want. But maybe you will see where you wrong.
Symbol ^ in regular expression means that following string should be at the beginning of URL. so you have to include entire path, see htaccess RewriteEngine for more examples
Your write RewriteRule twice. Try
RewriteRule decision/([0-9]+)$ /snap2/html/decision.php?PanelID=$1 [L, QSA]
Or
RewriteRule snap2/html/decision/([0-9]+)$ /snap2/html/decision.php?PanelID=$1 [L, QSA]
I'm trying to convert a simple url (below) in to a blog-style url, but not quite sure how to do it, all of my other rules are working fine, but I can't seem to figure this one out.
URL I want to convert: http://www.website.com/myblog.php?id=1&title=My+blog+title
URL I want it to create: http://www.website.com/1/my-blog-title
What should the rule be?
Any assistance appreciated :)
Try this
RewriteEngine on
RewriteBase /
RewriteRule ([0-9]+)/([^.]+) myblog.php?id=$1&title=$2
Try this in your .htaccess file:
RewriteEngine on
RewriteRule ^(\d+)/([^/]+)$ myblog.php?id=$1&title=$2
But here the hyphens are not replaced by plus signs.
in your .htaccess file,
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)$ /myblog.php?id=$1 [L]
You don't (well shouldn't) need to pass the blog title to the blog file, only the ID. Hope this works