Htaccess change url to directory url - .htaccess

For example, I want:
http://site.com/cool.php?page=woohoo
http://site.com/cool.php?page=yoyoyo
To show this in the browser:
http://site.com/woohoo/
http://site.com/yoyoyo/
How do I do this?

Check this answer: https://stackoverflow.com/a/8446690/995958
It gives a nice way to do exactly what you want to do.
Other answers are useful too if you have problems with the confirmed one.

Related

Redirecting a file using a fake folder

I'm trying to redirect a file using a fake folder, but I can not get it to work properly. I've been searching and trying different things but none of them worked out for me.
How my current URL looks like:
/new-weblog.php
How I want the URL to look like:
/weblogs/new-weblog.php
I do not want to redirect ALL urls to have the fake /weblogs/ folder. Only just for that one specific file.
Thank you in advance.
This doesn't qualify as an answer, however, this is a good tutorial that will give you the desired solution you're looking for and teach you about htaccess commands while you're at it.
Here's the link: https://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/

How do I redirect a page to another page in such a way that they both look the same?

I need to redirect https://example.com/projects/issues/(some_text_here) to http://example.com/i/(same_text_here) in such a way that it /i/(same_text_here) shows the same page that /projects/issues/(some_text_here) shows. Is this possible? How would I do this. Please post the code I would use (along with helpful comments explaining why something goes where it does). Thanks!
EDIT: I believe I would have to use the htaccess file?
EDIT 2: By (some_text_here) I mean so random text, like a wildcard. It could be /projects/issues/34... or /projects/issues/hello. In this case first example should redirect to /i/34, and the second example should redirect to /i/hello
Try this out in your .htaccess:
Redirect /projects/issues/ http://example.com/i/

Trying to create seo friendly url

I'm trying to create friendly url for my site but with no success :(( and i have two questions
The first is:
How to change the url from domain.com/page/something.php to domain.com/something
And the second is:
Will the changes make duplicate content and if how to fix the problem.
Thank you for your time,
Have a nice day
Check out the official URL Rewriting guide: http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
You'll be using the simplest use case, Canonical URLs. Assuming you have no other pages that you need to worry about, you can use a rule like this: (note: untested, your usage may vary)
RewriteRule ^/(.*)([^/]+)$ /$1$2.php
While that example might not exactly work for your use case, hopefully reading the guide and my example will help you get you on your way.

Is this possible with an htaccess rewrite

I am wondering if this is possible to do with an .htaccess rule.
My beginning url:
http://cmfi.org/wherewework/missionary/?missionary=ttaho%2C
What I want to end up with:
http://cmfi.org/wherewework/missionary/ttaho
The ttaho will change according to the page.
Thanks for any input.
Don't think I was asking anyone to code this for me...Just asking if it was possible. I have tried a few things and couldn't get them to work. The %2c is an encoded part of the url that is added from the plugin I was using.
I will figure it out. No worries.

Domain name slash user name redirect to PHP page

I would like to find a way for users to be able to type their username after my domain name to access their public profile page.
For example, if you type youtube.com/username it shows that user's channel page. The resulting page is the same as youtube.com/user/username.
So with my website, I have mydomain.example/users/profile.php?name=username
It's a bit more complicated, with PHP and variables and subdirectories and everything... I would like that same page to display when I type mydomain.example/username
I really have no idea where to start with this, but I suspect it would be something in the .htaccess file, which I do have access to.
Thanks for any help!
edit: sorry this is a few days old, I've been having some other troubles and I haven't been able to test it until now. Anyway, it isn't working...
Just to recap, I want mydomain.example/username
to filter to
mydomain.example/users/profile.php?name=username
Thanks..
edit2: I found this also on stackoverflow... link text i tried tweaking that, and what was mentioned here a few days ago... but it still won't work. Any ideas?
I also keep finding pages that recommend the strategy this guy used: link text but it looks like that would cause more problems than it's worth.
Any ideas?
RewriteEngine on
RewriteRule ^user/(.*)$ profile.php?name=$1 [NC,B,QSA]

Resources