I want to rewrite the url using .htaccess
Here is my main url which will be accessed by public:http://example.com/watch?v=123456789
I want same values of get parameters but in new location:
http://example.com/index.php?v=123456789
How can i do this? Help will be appreciated! Thanks.
it could be something like.. (.htaccess at root level)
RewriteRule ^watch/?$ index.php [QSA,L]
The important thing is the QSA option ("QueryString Append")
Hope it helps!
Related
https://example.in/mesurements/index/booking/
something like
https://example.in/booking/
Someone help Me
To do this, you can add the following lines to your .htaccess file in the document root folder:
RewriteEngine On
RewriteRule ^booking/(.*)$ /mesurements/index/booking/$1
I have searched for my specific htaccess redirect from dynamic url to static url but can't found proper one. So here is the question.
I want to redirect
www.example.com/directory/?year=2014&month=September
www.example.com/directory/?year=2014&month=October
www.example.com/directory/?year=2015&month=December
and so on
To
www.example.com/directory/2014/September
www.example.com/directory/2014/October
www.example.com/directory/2015/December
and so on
Hope you will definitely help with step by step process and how it work.
Thanks in advance
You can do that in the /directory/.htaccess file:
RewriteEngine on
RewriteRule ^(\d+)/(\w+)/?$ ?year=$1&month=$2 [L]
Usually is the other way aroud, but I need to redirect my static urls to dynamic ones as a variable part of the first one.
I need to redirect:
http:/example.com/sub1/sub-2/2014147-test-page-45x.html
http:/example.com/sub1/sub-6/8014149-test-24page.html
http:/example.com/sub1/sub-25/7514157-58test-page.html
to
http://example.com/sub1/testing.php?s=2014147
http://example.com/sub1/testing.php?s=8014149
http://example.com/sub1/testing.php?s=7514157
I know I need to use %{REQUEST_URI}, but I can't put it together.
Any help will be appreciated.
Thanks.
Assuming your .htaccess is at root of example.com, adding following to it will do the trick.
RewriteEngine On
RewriteBase /
RewriteRule ^sub1/[^/]+/(\d+).*$ sub1/testing.php?s=$1 [R,L]
This should work:
RewriteEngine on
RewriteRule ^sub1/(.*)/([0-9]+)-(.*)$ /sub1/testing.php?s=$2 [R=301,L]
I would like to write a url from
Original URL
www.xyz.com/folder/articles?id=1221
to rewrite URL
www.xyz.com/folder/article-title-1221.html
Would this be possible? I am wanting to creates dynamic pages based on the id in the url.
Thanks in advance
Try this:
RewriteRule folder/article-title-([0-9]+)\.html$ folder/articles?id=$1 [L]
I am wanting to rewrite a url like:
http://my.project/mydomain.com/ANY_NUMBER_OF_CATEGORIES/designer/4/designer-name/page.html
to this:
http://my.projects/mydomain.com/ANY_NUMBER_OF_CATEGORIES/page.html?designer=4
I would like to use mod-rewrite to accomplish this.
Things to note:
Any number of categories can be between 'mydomain.com/' and '/designer'. For instance the url could be http://my.project/mydomain.com/designer/4/designer-name/page.html or it could be http://my.project/mydomain.com/tops/shirts/small/designer/4/designer-name/page.html
A query string may be provided in the original url that needs to be preserved in the rewritten url.
For example url provided could be: http://my.project/mydomain.com/designer/4/designer-name/page.html?color=red&type=shirt
Given the url above the resulting url would need to be: http://my.projects/mydomain.com/page.html?designer=4&color=red&type=shirt
The order of the query string does not matter. The 'designer=4' part could come before or after the rest of the query string.
I'm new to .htaccess and re-writes so any examples and or explanations would be greatly appreciated. Thank you very much.
Try this in your .htaccess file:
RewriteEngine on
RewriteRule ^(.+/)?(\d+)/[^/]+/([^/]+\.html)$ $1$3?designer=$2 [L,QSA]
I ended up having to create two separate RewriteRules:
RewriteRule ^designer/([^/]+)/.*/([^/]+)\.html $2.html?designer=$1 [NC,L,QSA]
RewriteRule (.*)/designer/([^/]+)/.*/([^/]+)\.html $1/$3.html?designer=$2 [NC,L,QSA]
Thanks to Gumbo for pointing out the [QSA] portion of the rewrite.