Rewrite URL case - .htaccess

I have the following URL: http://sitename.com/?parameter_1=data&parameter_2=data
it always remains the same with the same data. I want it to be converted into the following URL: http://sitename.com/most-popular
I believe it is quite simple to do it from .htaccess but I am not familiar with rewrite rules.
Thank you.

If I correctly understand what you mean, you could try this
RewriteRule ^most-popular/?$ ?parameter_1=data&parameter_2=data [L]

Related

htaccess from old forum url to new one

until now I have always used htaccess to rewrite URLS in order to have non-SEF url to SEF urls.
Today I am facing a new challenge that honestly, beeing non confident in regular expression, I really don't know how to achieve.
I have a situation where a forum on a website of mine has been update in the following form:
previous link: www.domain.com/forum3/topic/name-of-topic/post/7548
new link: forum.domain.com/Topic-name-of-topic/
How do I intercept /post/37764 string and tell htaccess to not consider it?
And how to instruct the server to build that kind of url instead of the provious. I am very confused about it.
Any suggestion? Thank you very much. Is there any resource that I can read to help me better understand the case?
Thanks again.
EDIT
Florian answer is correct. I just added few mods to fit it better.
RewriteEngine On
#RewriteBase /
RewriteRule ^forum3/topic/([^/]+)/post/[0-9]+$ http://forum.domanin.com/Topic-$1/ [L,R=301]
RewriteRule ^forum3/topic/([^/]+)-[0-9]+$ http://forum.domanin.com/Topic-$1/ [L,R=301]
You can try this code :
RewriteEngine On
RewriteBase /
RewriteRule ^forum3/topic/([^/]+)/post/[0-9]+$ /Topic-$1/ [L,R=301]
/([^/]+)/ means that we want to catch a string containing one or more characters except / preceded and followed by a /.
This link might help you to test your .htaccess files :
Test your apache htaccess files online

URL rename not showing on Browser

I change my URL name using mod write. But my URL doesn't show the changes on browser.
This is how it looks from before and after
www.mydomain.com/toy/image.php
to this
www.mydomain.com/toy/xbox
How can I make this: www.mydomain.com/toy/xbox appear on the browser
Another words on my website it should appear www.mydomain.com/toy/xbox instead of this
www.mydomain.com/toy/image.php
This is my code:
RewriteEngine On
RewriteRule ^toy/xbox$ /toy/image.php* [L,R]
Can someone to explain to me how it works. Did I missed a step? Do I need to used PHP?
If I did make a mistake, correct me so I can learn from my mistakes. I try to google this but I couldn't find what I need to do
Any links or explanations would be appreciated. Thanks.
For it to "show the URL," you need it to do a 301/302 redirect, with a location header. All you have to do is end your RewriteRule line with [L,R=301]
You must perform a redirect using the R flag instead of just a rewrite.
RewriteRule ... ... [R]

.htaccess query rewrite rules

I am trying to make it for when a client loads the website:
http://www.example.com/docs/example
To actually load the address:
http://www.example.com/docs.php?doc=example
But not have it redirect. I have had mixed success with this, but it seems that there is not clear documentation on how this specific rewrite rule is made. If I actually knew regular expressions, then it would make this a lot easier i understand, but I am seeking some help on how to perform this.
Thanks so much!
In the htaccess file in your document root, add these rules:
RewriteEngine On
RewriteRule ^/?docs/(.*)$ /docs.php?doc=$1 [L]
Don't use the http://hostname/ or the R flag and it shouldn't redirect.

.htaccess RewriteRule help

I've been trying to create a rule.
If anyone could help, I would be extremely grateful.
Request: domain.com/c/wb.php?p=rs/rs/1tb/25n/ru/rs
Rewrite to: domain.com/c/wb/rs/rs/1tb/25n/ru/rs
Thanks in Advance
I think you have this a bit backwards. The idea behind URL rewriting is that you take a nice neat URL like this (what the user sees):
http://domain.com/c/wb/rs/rs/1tb/25n/ru/rs
and rewrite it behind the scenes into an uglier but PHP etc. friendlier URL like this (what the server processes):
http://domain.com/c/wb.php?p=rs/rs/1tb/25n/ru/rs
To do that, use this:
RewriteEngine On
RewriteRule ^/c/wb/(.*) http://domain.com/c/wb.php?p=$1 [L, NS]
It should look something like this
RewriteRule ^(c/wb)\.php\?p=(rs/rs/1tb/25n/ru/rs)$ $1/$2 [L,NS]
Still I'm not sure if you need slash in front of c/wb if you're using this in your .htaccess file. You need slash if you're using this in the VirtualHost configuration.

How to beautify the URL?

I am sick of this kind of URL:
www.domain.com/something/?id=person&photos=photoID&variable1=others&...
I am using apache, learning to write .htaccess now. Can anyone show me the basic code for this one?
Ugly:
www.domain.com/something/?id=person&photos=photoID
Goal:
www.domain.com/something/person/photoID
RewriteEngine on
RewriteRule ^something/(.*)/(.*)$ something/?id=$1&photos=$2 [QSA]
This is an extremely helpful article on Mod_Rewrite

Resources