hello I have this url http://localhost/index.php?a=group&name=groupname
I would like it to look like http://localhost/group/groupname
where a= is dynamic and name same thing.For htaccess
Try :
RewriteEngine On
RewriteRule ^([^./]+)/groupname/?$ /index.php?a=$1&name=groupname [QSA,NC,L]
This will rewrite :
http://example.com/foo/groupname
to
http://example.com/index.php?a=foo&name=groupname
Edit :
If the groupname is also dynmic, then in the patten, just replace groupname with ([^/]+) and replace name=groupname with name=$2 in the target path.
Related
I have url localhost/product/q.php?id=1&product=my-product
how to make the url into localhost/product/1/my-product using .htaccess
You use a RewriteRule which consists of a regex to apply to the pretty URL accessed by the user and a replacement which will then be used by the server/scripts.
RewriteRule ^product/(\d+)/(.*)$ /product/q.php?id=$1&product=$2 [L]
RewriteRule : Type of action
^product/(\d+)/(.*)$ : Regex to run against URL
/product/q.php?id=$1&product=$2 : Replacement URL
[L] : Flags; L == Last
Note
Having re-read the question you may need to add:
Options -MultiViews
To the top of your .htaccess file as well.
Redirect dynamic URL for below example :
https://hostname/en/content-page
to
https://hostname/en/storename/content-page
content-page is the dynamic parameters Like-
https://hostname/en/grocery/vegetables?fetchFacets=true#facet:&productBeginIndex:0&facetLimit:&orderBy:&pageView:grid&minPrice:&maxPrice:&pageSize:&
to
https://hostname/en/storename/grocery/vegetables?fetchFacets=true#facet:&productBeginIndex:0&facetLimit:&orderBy:&pageView:grid&minPrice:&maxPrice:&pageSize:&
OR
http://hostname/en/electronics?fetchFacets=true#facet:&productBeginIndex:0&facetLimit:&orderBy:&pageView:grid&minPrice:&maxPrice:&pageSize:&
to
http://hostname/en/storename/electronics?fetchFacets=true#facet:&productBeginIndex:0&facetLimit:&orderBy:&pageView:grid&minPrice:&maxPrice:&pageSize:&
add /storename or /en/storename in dynamic URLs
You should be able to just put /en/ in your pattern and then substitute it with an appended storename. Add this to your .htaccess file:
RewriteEngine On
RewriteRule ^en/(.*)$ https://hostname.com/en/storename/$1 [R=301,L]
That will redirect as you've asked in your examples.
Hello I have a url that is like that :
www.mysite.com/activation.php?token=d4ba10b14dedc7e7e7338ee8251670fa
What I would like to have is something like that :
www.mysite.com/Activation/Token/d4ba10b14dedc7e7e7338ee8251670fa
How can I do that please
You can put this rule in your htaccess (which has to be in root folder)
RewriteEngine On
RewriteRule ^Activation/Token/([^/]+)$ /activation.php?token=$1 [L]
I was using mod rewrite to create clean urls. I have urls like this :
http://www.sitename.com/viewcategory.php?id=262
I have rewritten successfully my url like this :
http://www.sitename.com/262
With the following mod_rewrite rule
RewriteEngine On
RewriteRule ^([a-zA-Z0-9]+)$ viewcategory.php?id=$1
RewriteRule ^([a-zA-Z0-9]+)/$ viewcategory.php?id=$1
What i want is to display the category name somthing like this:
http://www.sitename.com/categoryname
Please suggest me if there is a mistake in my rewrite rule or I need to do something else.
Thanks and regards.
How i rewrite url, using htaccess , i have tryed like this :
RewriteRule ^file$ file.php [L]
i don't want to be displayed the file extension
i want to rewrite url like this :
http://example.com/file.php into http://example.com/file
RewriteEngine on
RewriteRule ^file$ /file.php