.htaccess redirection with query string on url - php

I have a website www.example.com/blog/abc. I need it to redirect to www.example.com/blog/a.php?a=abc
Below is my .htaccess file
RewriteEngine On
RewriteBase /
RewriteRule ^blog/(.*)$ blog/a.php?a=$1 [R=301,L]
What am i doing wrong ?

Try:
RewriteRule ^blog/(.*)/?$ blog/a.php?a=$1
Instead of:
RewriteRule ^blog/(.*)$ blog/a.php?a=$1

Related

redirecting a php url with 2 parameter

I am trying to set up my api to have 2 endpoints, and the simplest way I have seen to do this is to have a .htaccess file that would redirect something like www.website.com/api/category/platform to display the same as www.website.com/api/index.php?category=platform . The issue I am now running into is that I want it to include a second parameter such as www.website.com/api/index.php?category=platform&filter=price to be the same as www.website.com/api/category/platform/price or even www.website.com/api/platform/price
The current .htaccess file is
RewriteEngine On
RewriteRule ^/?category/([^/d]+)/?$ index.php?category=$1 [L,QSA]
I figured it out and I was able to use something along the lines of
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)$ project3/api/index.php?category=$1&filter=$2 [L]
You can use smthing like this.
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?category$ $1category/ [R=301,L]
RewriteRule ^ - [L]
RewriteRule . index.php [L]

Redirect 301 of .htaccess didn't redirect correctly

My redirection in my .htacces doesn't want redirect correct url.
DefaultLanguage fr-FR
Options -Indexes
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^clic_go\.php\?id=(.+)$ /clic.php?id=$1 [R=301,L]
He redirect to :
/?id=4
i want :
/clic.php?id=4
Any idea ?
Thanks you =D
Use:
RewriteEngine on
RewriteCond %{QUERY_STRING} (?:^|&)id=(.+)(?:&|$) [NC]
RewriteRule ^clic_go\.php$ /clic.php?id=%1 [NC,R=301,L]
Because query string is not in the RewriteRule url.
With all the query string, you can just do:
RewriteEngine on
RewriteRule ^clic_go\.php$ /clic.php [NC,R=301,L]
Because without addition, it is copied

.htaccess code help in admin folder rewrite

i done url rewrite below in .htaccess
RewriteEngine On
RewriteBase /
RewriteRule ^admin/(.*) Rrrrr/core-.php [L]
RewriteRule (.*) Rrrrr/core.php [L]
All the files in admin folder should rewrite into core-.php
And all other files should rewrite into core.php
But all the files are rewriting into the core.php only.
http://www.konasignature.com/shop/women/dresses - this url working as per second command rule
But http://www.konasignature.com/admin/ - not working. 404 page only
This code works for me !
RewriteEngine on
RewriteRule ^admin/(.*) login/core-$1 [L]
Please use $ for this command
RewriteEngine On
RewriteBase /
RewriteRule ^admin/(.*)$ Rrrrr/core-.php [L]
RewriteRule (.*) Rrrrr/core.php [L]

.htaccess url rewriting

I need a rewrite rule to rewrite the following:
www.abc.com/page/xyz to www.abc.com/xyz
remove **"page"** from url
I think it's more like this:
RewriteBase /
RewriteRule ^(.*)$ page/$1 [L]
If I understand what you're trying to do.
Like so:
RewriteBase /
RewriteRule ^page(/.*)?$ $1 [L]
If you only want to redirect page/xyz then you can use:
RewriteEngine on
RewriteRule ^/page/xyz$ /xyz [L]
If you want to redirect anything within the page directory, then use:
RewriteEngine on
RewriteRule ^/page(/.*$)$ $1 [L]

apache rewrite static url to dynamic

I'm try to rewrite my url
http://www.domain.com/live/randomword
it should go rewrite to
http://www.domain.com/live/?cat=randomword
here are my tests:
RewriteRule ^live/(.*)$ /live/?cat=$1
RewriteRule ^live/(.*)$ live/?cat=$1
and all i have in the htaccess file is:
RewriteEngine on
You should try to add a RewriteBase / to your .htaccess and to suffix your rule with a [L] to say it's last rewrite rule ending with something like that:
RewriteEngine on
RewriteBase /
RewriteRule ^live/(.*)$ live/index.php?cat=$1 [L]
If this still doesn't work be sure to check that mod_rewrite is enabled
also you can do a [R,L] instead of [L] to see the redirection in the url and so have more info on what's going own.
hope this help
Have this code in your .htaccess file:
Options -MultiViews +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^live/(.*)$ /live/?cat=$1 [L,NC]
in rewrite rule the file name or extension in missing?
write rule like,
RewriteRule ^live/([a-zA-Z0-9_-]+)$ /viewcategory.php?cat=$1

Categories